#include <bits/stdc++.h>
using namespace std;
string s;
char l[26], r[26], t;
int n, m, i, k;
bool f;
char a, b, c;
int main() {
  memset(l, 'A', sizeof(l));
  memset(r, 'A', sizeof(r));
  cin >> n >> m;
  cin >> s;
  f = false;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    if (a == b) continue;
    if (l[a - 'a'] == 'A') {
      l[a - 'a'] = b;
      c = r[b - 'a'];
      f = true;
      r[b - 'a'] = a;
    } else {
      t = r[a - 'a'];
      l[t - 'a'] = b;
      c = r[b - 'a'];
      f = true;
      r[b - 'a'] = t;
    }
    if (l[b - 'a'] == 'A') {
      l[b - 'a'] = a;
      r[a - 'a'] = b;
    } else {
      if (f)
        t = c;
      else
        t = r[b - 'a'];
      l[t - 'a'] = a;
      r[a - 'a'] = t;
      f = 0;
    }
  }
  for (i = 0; i < n; i++) {
    if (l[s[i] - 'a'] != 'A')
      cout << l[s[i] - 'a'];
    else
      cout << s[i];
  }
  return 0;
}
