nc1c2

In the never-ending quest of promoting the contest, Comisia made its best effort to ensure that Mindcoding gained the popularity it deserved. For this, hundreds of posters have been issued and spread throughout the city.

One of the most attractive aspects of the contest resides in the prizes. However, one problem appears. Since publishing the posters, a few new sponsors have joined the initiative, and prizes have increased in value. It is known that every occurrence of digit c1 in the total prize value (labeled n) has been replaced with a new digit c2. Comisia is giving you a set of possible values of n. Your task is to apply all substitutions and output the result.

Note: you will receive full feedback for this problem.

Input

The input contains an unknown number of tests. Each test occupies one line of input, and contains three values: n c1 c2.
The last test will always be 0 0 0, indicating that your program should halt.

Output

For each test, you should output a single value on a separate line, equal to the new prize amount. You should not output anything for the 0 0 0 test.

Constraints

  • 0 ≤ c1, c2 ≤ 9
  • 0 ≤ n < 105, both before and after the transformation.
  • It is possible that n decreases in value after the transformation.
  • The number of tests does not exceed 15.

Sample

InputOutput
13543 3 9
6777 7 0
1234 1 0
0 0 0
19549
6000
234
Questions?

Sponsors Gold