def compute(n, p):
    n = list(n)
    p2 = int(n[-p])
    for i in range(len(n)-p):
        n[i] = str(int(n[i])+p2)[-1]
    for i in range((len(n)-p+1), len(n)):
        n[i] = str(abs(int(n[i])-p2))
    return "".join(n)
file = open("inputIntermediate.txt", 'r')
input1 = file.read().splitlines()
for i in range(len(input1)):
    input1[i] = input1[i].split(" ")
    ans = compute(input1[i][0], int(input1[i][1]))
    s = "{}. {}".format(i+1, ans)
    print (s)
file.close()