#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int maxn = 200000 + 5;
int n, m, vis[maxn], cnt[26];
char a[10], b[10], s[maxn];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    scanf("%s", s);
    for (int i = 0; i < n; i++) {
      int v = s[i] - 'a';
      vis[i] = v;
      cnt[v] = v;
    }
    while (m--) {
      scanf("%s%s", a, b);
      for (int i = 0; i < 26; i++) {
        if (cnt[i] == a[0] - 'a')
          cnt[i] = b[0] - 'a';
        else if (cnt[i] == b[0] - 'a')
          cnt[i] = a[0] - 'a';
      }
    }
    for (int i = 0; i < n; i++) {
      int v = s[i] - 'a';
      s[i] = cnt[v] + 'a';
    }
    printf("%s\n", s);
  }
  return 0;
}
