#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define mp make_pair #define pb push_back #define ff first #define ss second #define int64 unsigned long long int a[10]; int main(){ ios_base::sync_with_stdio(false); int n,c1,c2; while(true){ cin >> n >> c1 >> c2; if(n == 0 && c1 == 0 && c2 == 0) return 0; a[0] = 0; if(n == 0){ a[0] = 1; if(c1 == 0) a[1] = c2; else a[1] = 0; } while(n != 0){ a[0]++; if(n%10 == c1) a[a[0]] = c2; else a[a[0]] = n%10; n /= 10; } while(a[a[0]] == 0 && a[0] > 1) a[0]--; for(int i = a[0]; i >= 1; i--) cout << a[i]; cout << "\n"; } }