#include <bits/stdc++.h>
using namespace std;
char s[200005];
char x[26];
int n, m;
char a, b;
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    for (int i = 0; i < 26; i++) x[i] = i + 'a';
    getchar();
    scanf("%s", s);
    getchar();
    for (int i = 0; i < m; i++) {
      scanf("%c", &a);
      getchar();
      scanf("%c", &b);
      getchar();
      if (a == b) continue;
      for (int j = 0; j < 26; j++) {
        if (x[j] == a) {
          x[j] = b;
          continue;
        }
        if (x[j] == b) {
          x[j] = a;
          continue;
        }
      }
    }
    int k;
    for (int i = 0; i < n; i++) {
      k = s[i] - 'a';
      printf("%c", x[k]);
    }
    printf("\n");
  }
  return 0;
}
