# Takoma Park Middle School
# Int-3
# Contest 1
# River Qiu

f = open("1int_testdata.txt", "r")

for sample in range(1, 6):
       text = f.readline()
       text = text.split()
       number = text[0]
       position = int(text[1])
       digit = int(number[-(position)])
       numberLeft = number[:-(position)]
       numberRight = number[-(position)+1:]
       if position == 1:
              numberRight = ""
       newNumberLeft = ""
       newNumberRight = ""
       
       for x in numberLeft:
              theSum = str(int(x) + digit)
              replacement = theSum[-1]
              newNumberLeft += replacement
              
       for y in numberRight:
              theDifference = str(abs((int(y) - digit)))
              replacement = theDifference
              newNumberRight += replacement

       finalNumber = newNumberLeft + str(digit) + newNumberRight
       print(finalNumber)

f.close()