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