#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double esp = 1e-5;
char to[233];
char str[200233];
char a[3], b[3];
int main() {
  int n, m;
  for (int i = 'a'; i <= 'z'; ++i) to[i] = i;
  scanf("%d %d", &n, &m);
  scanf("%s", str);
  while (m--) {
    scanf("%s %s", a, b);
    for (int i = 'a'; i <= 'z'; ++i) {
      if (to[i] == a[0])
        to[i] = b[0];
      else if (to[i] == b[0])
        to[i] = a[0];
    }
  }
  for (int i = 0; str[i]; ++i) {
    char ch = str[i];
    str[i] = to[ch];
  }
  puts(str);
  return 0;
}
