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