#include <bits/stdc++.h>
using namespace std;
string s, a, b;
int c1, c2;
int id[30], mp[30];
int main() {
  int n, m;
  cin >> n >> m;
  cin >> s;
  memset(mp, -1, sizeof mp);
  for (int i = 0; i < 26; i++) id[i] = i;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    c1 = a[0] - 'a', c2 = b[0] - 'a';
    mp[id[c1]] = c2;
    mp[id[c2]] = c1;
    int t1 = id[c2], t2 = id[c1];
    id[c1] = t1;
    id[c2] = t2;
  }
  for (int i = 0; i < s.size(); i++) {
    if (mp[s[i] - 'a'] == -1)
      cout << s[i];
    else
      cout << (char)(mp[s[i] - 'a'] + 'a');
  }
  puts("");
}
