#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int n, m;
char s[maxn];
char a[128], x, y;
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 'a'; i <= 'z'; i++) a[i] = i;
    scanf("%s", s);
    for (int i = 1; i <= m; i++) {
      scanf(" %c %c", &x, &y);
      for (int i = 'a'; i <= 'z'; i++) {
        if (a[i] == x)
          a[i] = y;
        else if (a[i] == y)
          a[i] = x;
      }
    }
    for (int i = 0; s[i]; i++) s[i] = a[s[i]];
    puts(s);
  }
}
