#Jared Baza
#ACSL Contest Problem 1

import ovcc_grader

#---------------------------------------------------------------
def transform(N,P,D):
  if P > len(str(N)):#Checks if input is in specified range

    return('INVALID INPUT, PTH VALUE NOT IN RANGE OF N')#If input not valid, notify user
  
  l = [int(i) for i in str(N)] # Make N into a List of Integers
  
  V = int (l[-P]) # Value of Pth Digit from right of Integer List
  
  S1 = int(V + D) # First Sum Value

  ListS1 = [int(i) for i in str(S1)] # Create List of Int. from S1
    
  S2 = abs (V - D) # Second Sum
  ListS2 = [int(i) for i in str(S2)] # Create List of Int. from 2nd Sum
  
  if V <= 4: # Check if Pth Digit Value is less than or equal to 4
    l[-P] = ListS1[-1]  # Replace Position Pth from right with Units Value of Int. value from sum S1

    L_1 = l[:] # Placed/Store all Int. values from List l into List L_1
    
    for i in range (-(P-1),-0):
      l[i] = 0  #  FOR loop fuction to place zeros in List l that are after range value P
      

    N_Transformed = int (''.join([str(i) for i in l])) # Converts List of Integers to list of Strings using FOR LOOP
                                                         #Joins List of Strings into Single Integer Value

    return N_Transformed  # Returns value of N_Transformed
    
  else:
    if 4 < V <= 9:   # Repeat process when Pth Position Value(V)is greater than 4 but less than or equal to 9

      l[-P] = ListS2[0]
      L_1 = l[:]
      for i in range (-(P - 1),-0):
        l[i] = 0

      N_Transformed = int(''.join([str(i) for i in l]))
      
      return N_Transformed
      
  #----------------------------------------------------------

input = ovcc_grader.readinput()

ovcc_grader.clearoutput()
for line in input:
  N = line[0]
  P = line[1]
  D = line[2]
  ovcc_grader.writeoutput(transform(N,P,D))