#include<stdio.h>
struct pasw
{
char input;
char output;
}txt[100];
int main()
{ int i=0,z=0;
char filename[15],mima[15],ch,c;
scanf("%s",mima);
scanf("%s",filename);
FILE *fp1,*fp2;
fp2 = fopen(mima,"r");
fp1 = fopen(filename,"r");
while((ch = fgetc(fp2))!=EOF)
{ if(ch!=','&&z%2==0&&ch!='\n')
{
txt[i].input = ch;z++;
}
else if(ch!=','&&z%2==1&&ch!='\n')
{
txt[i].output = ch;z++;
i++;
}
}
z = sizeof(txt)/sizeof(struct pasw);
ch++;
while((ch = fgetc(fp1))!= EOF)
{ for(i=0;ch!=txt[i].input&&i<=z;i++);
if(i<z) printf("%c",txt[i].output);
else printf("%c",ch);
}
fclose(fp1);
fclose(fp2);
}