#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;

}