#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, m;
int a[maxn];
char s[maxn];
void solve() {
  map<char, char> h;
  for (int i = 0; i < 26; i++) {
    char c = i + 'a';
    h[c] = '5';
  }
  for (int i = 0; i < m; i++) {
    char l, r;
    cin >> l >> r;
    for (int j = 0; j < 26; j++) {
      char c = j + 'a';
      if (h[c] == l) {
        h[c] = r;
        continue;
      }
      if (h[c] == r) {
        h[c] = l;
        continue;
      }
    }
    if (h[l] == '5') h[l] = r;
    if (h[r] == '5') h[r] = l;
  }
  for (int i = 1; i <= n; i++) {
    if (h[s[i]] == '5')
      printf("%c", s[i]);
    else
      printf("%c", h[s[i]]);
  }
  printf("\n");
}
int main() {
  while (scanf("%d %d", &n, &m) != EOF) {
    cin >> (s + 1);
    getchar();
    solve();
  }
  return 0;
}
