#include <iostream>
using namespace std;
int main()
{
string from,to;
getline(cin,from);
getline(cin,to);
string line;
while(getline(cin,line))
{
if (from!=to)
{
int lastpos = 0;
while ((lastpos=line.find(from, lastpos))!=string::npos)
{
line.replace(lastpos,from.length(),to);
lastpos+=from.length();
}
}
cout << line << endl;
}
}