#include <bits/stdc++.h>
using namespace std;
map<char, char> mp;
int n, m, i;
char a, b, c;
string s;
int main() {
  cin >> n >> m >> s;
  for (i = 0; i < n; i++) mp[s[i]] = s[i];
  while (m--) {
    cin >> a >> b;
    for (c = 'a'; c <= 'z'; c++)
      if (a == mp[c])
        mp[c] = b;
      else if (b == mp[c])
        mp[c] = a;
  }
  for (i = 0; i < n; i++) cout << mp[s[i]];
  return 0;
}
