#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <sstream>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <iterator>

using namespace std;

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define INF 1e9
#define ll long long
#define ull unsigned long long

int main()
{
  //  freopen("C:\\Users\\Sonia\\Documents\\mindCoding.ro\\in.txt", "r", stdin);
    string str, a, b;
    while((cin >> str >> a >> b) && (str != "0" || a != "0" || b != "0"))
    {
        bool first = true;
        int n = str.length();
        for(int i = 0; i < n; i++)
        {

            if(str.substr(i,1) == a)
            {
                if(first)
                {
                    if(b != "0")
                    {
                        cout << b;
                        first = false;
                    }
                }
                else //if(!first)
                    cout << b;
            }
            else
            {
                if(first)
                    first = false;
                cout << str[i];
            }
        }
        if(first)
            cout << "0";
        cout << endl;
    }

    return 0;
}