#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[26];
  for (int i = 0; i < 26; i++) a[i] = '1';
  int l;
  cin >> l;
  int q;
  cin >> q;
  string s;
  cin >> s;
  char c, d;
  int st1 = 0, st2 = 0;
  int num1 = 0, num2 = 0;
  for (int i = 0; i < q; i++) {
    cin >> c >> d;
    if (c == d)
      continue;
    else {
      st1 = 0, st2 = 0;
      for (int i = 0; i < 26; i++) {
        if (a[i] == c) {
          st1 = 1;
          num1 = i;
        }
        if (a[i] == d) {
          st2 = 1;
          num2 = i;
        }
        if (st1 == 1 && st2 == 1) break;
      }
      if (st1 == 1) a[num1] = d;
      if (st2 == 1) a[num2] = c;
      if (st1 == 0) {
        a[c - 'a'] = d;
      }
      if (st2 == 0) {
        a[d - 'a'] = c;
      }
    }
  }
  for (int i = 0; i < l; i++) {
    if (a[s[i] - 'a'] == '1')
      continue;
    else
      s[i] = a[s[i] - 'a'];
  }
  cout << s;
}
