//Matthew Modi
//Cary Academy INT-3
//ACSL Contest #1

import fileinput
import sys

line_num = 0

for input_line in fileinput.input('input.txt'):
    try:
        line_num += 1

        N = [int(char) for char in input_line.split()[0]]
        P = int(input_line.split()[1])

        for i in range(0, len(N)-P):
            N[i] = (N[i]+N[len(N)-P])%10
        
        for i in range(len(N)-P+1, len(N)):
            N[i] = abs(N[i]-N[len(N)-P])
        
        print(str(line_num) + ". " + "".join(map(str, N)))
    except:
        print("Error on line " + str(line_num))