# -----------------------------------------------------------------------------------------
# Oak Valley Coding Club 2019-2020
# Solution for 2020 ACSL Programming Problem #1 – Junior Division
# Author :  Divyanshi	Suri
# Language: Python 3.x
# -----------------------------------------------------------------------------------------


#-----------------------------------------------
# Main Function to solve the problem
def Number_Transform(N,P,D):
    count = 0
    num = 0
    while (count != P):
        num = N%10
        N = N//10
        count = count + 1
    if(num <=4):
        num = num + D
    else:
        num = abs(num - D)

    if (num == 10):
        num = 1
    elif (num > 10):
        while (num > 10):
            num = num/10
            num = int(num)
    num = (10**P) * num
    out = str(N) + str(num)
    out = int(out)
    out = int(out/10)
    return (out )


#-----------------------------------------------
# Auxiliary code for reading input and writing output
input = 'input.txt'
output = 'output.txt'

def readinput():
  words=[]
  with open(input) as f:
    lines = f.readlines()
    for line in lines:
      if line.split()!=[]:
        words.append(line.split())
  for j in range (0,len(words)):
    for i in range(0,len(words[j])):
      words[j][i]=int(words[j][i])
  return words


def writeoutput(line):
  with open(output,'a') as f:
     f.write(str(line)+'\n')

def clearoutput():
  f=open(output,'w')
  f.write('')

allinputs = readinput()

clearoutput()
for line in allinputs:
    N = line[0]
    P = line[1]
    D = line[2]
    out = Number_Transform(N, P, D)
    writeoutput(out)