#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
char x,y;
int magic[30]; //It is an array where magic happens
string str;
cin>>n>>m;
cin>>str;
for(int i=0;i<26;++i){ // magic[0] means value of 'a' and so on
magic[i]=i;
}
for(int i=1;i<=m;++i){
cin>>x>>y;
int posa,posb;
for(int j=0;j<26;++j){ //search for the value which corresponds to x and search for value which corresponds to y
if(magic[j]==x-'a'){
posa=j;
}
if(magic[j]==y-'a'){
posb=j;
}
}
magic[posa]=y-'a'; //if 'a' is replaced by 'b' by one of the persons then magic[0] will keep 1(the value of 'b')
magic[posb]=x-'a'; //and magic[1] will contain 0(the value of 'a')
}
// magic array contains final values of each character
int len=str.size();
for(int i=0;i<len;++i){
str[i]=magic[str[i]-'a']+'a';
}
cout<<str<<'\n';
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCl7CgogICAgaW50IG4sbTsKCiAgICBjaGFyIHgseTsKCiAgICBpbnQgbWFnaWNbMzBdOyAgIC8vSXQgaXMgYW4gYXJyYXkgd2hlcmUgbWFnaWMgaGFwcGVucwoKICAgIHN0cmluZyBzdHI7CgogICAgY2luPj5uPj5tOwoKICAgIGNpbj4+c3RyOwoKICAgIGZvcihpbnQgaT0wO2k8MjY7KytpKXsgIC8vIG1hZ2ljWzBdIG1lYW5zIHZhbHVlIG9mICdhJyBhbmQgc28gb24KCiAgICAgICAgIG1hZ2ljW2ldPWk7CgogICAgfQoKICAgCiAKICAgIGZvcihpbnQgaT0xO2k8PW07KytpKXsKCiAgICAgICAgY2luPj54Pj55OwoKICAgICAgICBpbnQgcG9zYSxwb3NiOwoKICAgICAgICBmb3IoaW50IGo9MDtqPDI2Oysrail7ICAgIC8vc2VhcmNoIGZvciB0aGUgdmFsdWUgd2hpY2ggY29ycmVzcG9uZHMgdG8geCAgYW5kIHNlYXJjaCBmb3IgdmFsdWUgd2hpY2ggY29ycmVzcG9uZHMgdG8geQoKICAgICAgICAgICAgIGlmKG1hZ2ljW2pdPT14LSdhJyl7CiAgICAgICAgICAgICAgICAgcG9zYT1qOwogICAgICAgICAgICAgfSAgIAogICAgICAgICAgICAgIAogICAgICAgICAgICAgaWYobWFnaWNbal09PXktJ2EnKXsKICAgICAgICAgICAgICAgICBwb3NiPWo7IAogICAgICAgICAgICAgfSAgICAgICAKICAgICAgICB9CgogICAgICAgIG1hZ2ljW3Bvc2FdPXktJ2EnOyAgIC8vaWYgJ2EnIGlzIHJlcGxhY2VkIGJ5ICdiJyBieSBvbmUgb2YgdGhlIHBlcnNvbnMgdGhlbiBtYWdpY1swXSB3aWxsIGtlZXAgMSh0aGUgdmFsdWUgb2YgJ2InKQoKICAgICAgICBtYWdpY1twb3NiXT14LSdhJzsgIC8vYW5kIG1hZ2ljWzFdIHdpbGwgY29udGFpbiAwKHRoZSB2YWx1ZSBvZiAnYScpCiAgICAgIAogICAgfQoKCiAgIC8vIG1hZ2ljIGFycmF5IGNvbnRhaW5zIGZpbmFsIHZhbHVlcyBvZiBlYWNoIGNoYXJhY3RlcgogIAoKICAgIGludCBsZW49c3RyLnNpemUoKTsKCiAgICBmb3IoaW50IGk9MDtpPGxlbjsrK2kpewoKICAgICAgICAgc3RyW2ldPW1hZ2ljW3N0cltpXS0nYSddKydhJzsKICAgCiAgICB9CgogICAgY291dDw8c3RyPDwnXG4nOwoKICAgIHJldHVybiAwOwoKfQ==