#include <iostream>
#include <string.h>
using namespace std;

int main()
{
	char n[100005];
	char *p, *q, *y;
	while (true)
	{
		cin.getline(n, 100005);
		p = strtok(n, " ");
		q = strtok(NULL, " ");
		y = strtok(NULL, " ");

		if (p[0] == '0' && q[0] == '0' && y[0] == '0' )
		{
			break;
		}

		for (int i = 0; i < strlen(n); i++)
		{
			if (p[i] == q[0]){
				cout << y[0];
			}
			else
				cout << p[i];
		}

		cout << "\n";

	}
	return 0;
}