#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const int maxn = 300005;
int n, m;
char s[maxn], a[3], b[3];
int ch[30], f[30];
int main() {
  while (cin >> n >> m) {
    for (int i = 0; i <= 26; i++) {
      ch[i] = i;
      f[i] = i;
    }
    scanf("%s", s);
    int x, y;
    for (int i = 0; i < m; i++) {
      scanf("%s %s", a, b);
      x = a[0] - 'a';
      y = b[0] - 'a';
      swap(ch[f[x]], ch[f[y]]);
      swap(f[x], f[y]);
    }
    for (int i = 0; i < n; i++) {
      printf("%c", ch[s[i] - 'a'] + 'a');
    }
    printf("\n");
  }
  return 0;
}
