def split_line(l):
    str = l.split(' ')
    return str

line_num = 1

with open('1int_testdata.txt') as file:
    line = file.readline()
    while line:
        line = line.strip()
        
        s, index = split_line(line)
        index_num = int(index)
        
        splitter = s[-index_num]
        splitter_num = int(splitter)
        
        len_s = len(s)
        s1 = list(s[:(len_s - index_num)])
        s2 = list(s[(len_s - index_num + 1):len_s])
        
        for i in range(0, len(s1)):
            value = int(s1[i])
            s1[i] = str((value + splitter_num) % 10)
        
        for i in range(0, len(s2)):
            value = int(s2[i])
            s2[i] = str(abs(value - splitter_num))
        
        output= "".join(s1) + splitter + "".join(s2)
        print(str(line_num) + ". " + output)
        
        line_num = line_num + 1
        line = file.readline()