#include<bits/stdc++.h>
int main()
{
int n,m;
char a[200001],b,c,i,j;
scanf("%d%d",&n,&m);
fflush(stdin);
scanf("%s",a);
for(i=0;i<m;i++)
{
fflush(stdin);
scanf("%c %c",&b,&c);
for(j=0;j<n;j++)
{
if(a[j]==b) a[j]=c;
else if(a[j]==c) a[j]=b;
}
}
printf("%s\n",a);
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KaW50IG1haW4oKQp7CiAgICBpbnQgbixtOwogICAgY2hhciBhWzIwMDAwMV0sYixjLGksajsKICAgIHNjYW5mKCIlZCVkIiwmbiwmbSk7CiAgICBmZmx1c2goc3RkaW4pOwogICAgc2NhbmYoIiVzIixhKTsKICAgIGZvcihpPTA7aTxtO2krKykKICAgIHsKICAgICAgICBmZmx1c2goc3RkaW4pOwogICAgICAgIHNjYW5mKCIlYyAlYyIsJmIsJmMpOwogICAgICAgIGZvcihqPTA7ajxuO2orKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKGFbal09PWIpIGFbal09YzsKICAgICAgICAgICAgZWxzZSBpZihhW2pdPT1jKSBhW2pdPWI7CiAgICAgICAgfQogICAgfQogICAgcHJpbnRmKCIlc1xuIixhKTsKICAgIHJldHVybiAwOwp9