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