#include #include using namespace std; void splitInDigits(long n, vector &x) { while (n != 0) { x.push_back(n % 10); n = n / 10; } } int main() { int t = 0; long n; int c1, c2; while (t < 15) { int count = 0; cin >> n >> c1 >> c2; if (n == 0 && c1 == 0 && c2 == 0) break; vector v; splitInDigits(n, v); for (long i = 0; i < v.size(); i++) { if (v[i] == c1) v[i] = c2; } for (long i = v.size() - 1; i >= 0; i--) { while (v[i] == 0 && count < 1) { i--; } if (i >= 0) { cout << v[i]; count++; } } t++; } return 0; }