#include<algorithm> #include<bitset> #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<ctime> #include<deque> #include<fstream> #include<iomanip> #include<iostream> #include<map> #include<queue> #include<set> #include<stack> #include<unordered_map> #include<unordered_set> #include<utility> #include<vector> using namespace std; #define dbg(x) (cout<<#x<<" = "<<(x)<<'\n') #ifdef HOME const string inputFile = "input.txt"; const string outputFile = "output.txt"; #else const string problemName = ""; const string inputFile = problemName + ".in"; const string outputFile = problemName + ".out"; #endif typedef long long int lld; typedef pair<int, int> PII; typedef pair<int, lld> PIL; typedef pair<lld, int> PLI; typedef pair<lld, lld> PLL; const int INF = (1LL << 31) - 1; const lld LINF = (1LL << 62) - 1; const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1}; const int MOD = (int)(1e9) + 7; const int NMAX = 100000 + 5; const int MMAX = 100000 + 5; const int KMAX = 100000 + 5; const int PMAX = 100000 + 5; const int LMAX = 100000 + 5; const int VMAX = 100000 + 5; int N, a, b; deque<int> V; int main() { #ifdef HOME freopen(inputFile.c_str(), "r", stdin); freopen(outputFile.c_str(), "w", stdout); #endif while(scanf("%d%d%d", &N, &a, &b) + 1) { if(!N && !a && !b) break; V.resize(0); if(N == 0) V.push_back(0); while(N) { V.push_back(N % 10); N /= 10; } reverse(V.begin(), V.end()); for(auto &x : V) if(x == a) x = b; while(V.front() == 0 && V.size() > 1) V.pop_front(); for(auto x : V) printf("%d", x); printf("\n"); } return 0; }