#include using namespace std; int v[3][15]; int x, hatv, db; void read(int i) { cin >> v[0][i]; cin >> v[1][i]; cin >> v[2][i]; } int main() { db = 0; read(db); while (v[0][db]!=0){ db++; read(db); } for (int i = 0; i < db; i++) { x = 0; hatv = 1; while (v[0][i] != 0) { if (v[0][i] % 10 == v[1][i]) { x += v[2][i] * hatv; } else x += v[0][i]%10 * hatv; v[0][i] /= 10; hatv *= 10; } cout << x << endl; } return 0; }