#include <bits/stdc++.h>
using namespace std;
const int maxn = 210000;
char pattern[maxn];
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    char str[30];
    for (int i = 0; i < 26; i++) {
      str[i] = 'a' + i;
    }
    scanf("%s", pattern);
    char p, q;
    for (int i = 0; i < m; i++) {
      getchar();
      scanf("%c %c", &p, &q);
      for (int j = 0; j < 26; j++) {
        if (str[j] == p) {
          str[j] = q;
        } else if (str[j] == q) {
          str[j] = p;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      printf("%c", str[pattern[i] - 'a']);
    }
    puts("");
  }
  return 0;
}
