#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 100;
char s[N];
char rev[50];
int main() {
  int n, m;
  scanf("%d %d\n", &n, &m);
  gets(s);
  memset(rev, 0, sizeof(rev));
  while (m--) {
    char x, y;
    scanf(" %c %c", &x, &y);
    if (x == y) continue;
    for (int i = 1; i <= 30; i++) {
      if (rev[i] == x)
        rev[i] = y;
      else if (rev[i] == y)
        rev[i] = x;
    }
    if (rev[x - 'a' + 1] == 0) rev[x - 'a' + 1] = y;
    if (rev[y - 'a' + 1] == 0) rev[y - 'a' + 1] = x;
  }
  for (int i = 0; i < n; i++) {
    if (rev[s[i] - 'a' + 1] == 0)
      printf("%c", s[i]);
    else
      printf("%c", rev[s[i] - 'a' + 1]);
  }
  printf("\n");
  return 0;
}
