#include <iostream>
using namespace std;
int rep_n(int a, int b, int c){
int i = a;
int h = a;
int j = 1;
while(i > 0){
    if(i%10 == b){
        if(c < b){
            h-=(b-c)*j;
        }else{
            h+=(c-b)*j;
        }
    }
    i /= 10;
    j *= 10;
}
return h;
}
int main(){
    int tests[15];
    int i = 0;
    int n,ce,ck;
    cin >> n >> ce >> ck;
    while(n + ce + ck != 0){
        tests[i] = rep_n(n,ce,ck);
        ++i;
        cin >> n >> ce >> ck;
    }
    for(int j=0; j < i; ++j){
            if(j+1 != i){
        cout << tests[j] << endl;
            }else{
        cout << tests[j];
            }
    }
}