#ACSL1920J1. Number Transformation

Number Transformation

PROBLEM:​ Given a positive integer (call it ​N​), a position​ ​in that integer (call it ​P​), and a transition integer (call it ​D​). Transform ​N​ as follows:

● If the ​Pt​h​ digit of ​N​ from the right is from​ ​0 to 4, add ​D​ to it. Replace the ​Pt​h​ digit by the units digit of the sum. Then, replace all digits to the right of the ​Pt​h​ digit by 0.

● If the ​Pt​h​ digit of ​N​ from the right is from​ ​5 to 9, subtract ​D​ from it. Replace the ​Pt​h​ digit by the leftmost digit of the absolute value of the difference. Then, replace all digits to the right of the ​Pt​h​ digit by 0.

Example 1: N = 7145032, P = 2, D = 8 . ​The 2​nd​ digit from the right is 3; add 8 to it (3+8=11), and replace the 3 with 1 to get 7145012. Replace the digits to the right by 0s to get 7145010.

Example 2: N = 1540670, P = 3, D = 54 . ​The 3​rd​ digit from the right is 6; the absolute value of 6-54 is 48; replace with the 4 to get 1540470. Replace the digits to the right with 0s to get 1540400.

INPUT: ​There will be 5 sets of data. Each set contains 3 positive integers: ​N, P​, and ​D. N​ will be less than 1015 ; ​P ​and​ D​ will be valid inputs. No input will cause an output to have a leading digit of 0.

OUTPUT: ​Print the transformed number. The printed number may not have any spaces between the digits.

SAMPLE INPUT:

124987 2 3
540670 3 9
7145042 2 8
124987 2 523
4386709 1 2

SAMPLE OUTPUT:

124950
540300
7145020
124950
4386707