#include "iostream" using namespace std; int main() { int n, c1, c2, n2, car, i, j; for(i = 0; i < 15; i++) { cin >> n >> c1 >> c2; if( !(n || c1 || c2)) return 0; else { n2 = 0; j = 1; do{ car = n %10; if(car == c1) n2 += c2 * j; else n2 += car * j; n = n/10; j *= 10; }while(n != 0); } cout << n2 << endl; } return 0; }