#include <bits/stdc++.h>   using namespace std;   const int maxn = 2000010;   int main() {     int len, cnt;     char s, d, st[maxn], word[26];     cin >> len >> cnt;     cin >> st;     for (int i = 0; i < 26; ++i) {       word[i] =  a  + i;     }     for (int i = 1; i <= cnt; ++i) {       cin >> s >> d;       if (s == d) continue;       for (int j = 0; j < 26; ++j) {         if (word[j] == s)           word[j] = d;         else if (word[j] == d)           word[j] = s;       }     }     for (int i = 0; i < len; ++i) cout << word[st[i] -  a ];     cout << endl;     return 0;   }   