#include <bits/stdc++.h>
using namespace std;
char ch[2 * 100005];
int r[300];
char i[5], j[5];
int main() {
  int a, b, c, d, e, x, y, z, n, m;
  scanf("%d %d", &n, &m);
  scanf("%s", ch);
  for (a = 0; a < 26; a++) {
    r[a] = a;
  }
  while (m--) {
    scanf("%s %s", i, j);
    x = i[0] - 'a';
    y = j[0] - 'a';
    for (b = 0; b < 26; b++) {
      if (r[b] == x) {
        r[b] = y;
        continue;
      }
      if (r[b] == y) {
        r[b] = x;
        continue;
      }
    }
  }
  for (a = 0; a < n; a++) printf("%c", r[ch[a] - 'a'] + 'a');
  printf("\n");
  return 0;
}
