#include <bits/stdc++.h>
const int maxn = 200000 + 10;
using namespace std;
char str[maxn], s[maxn];
char a[5], b[5];
int w[35];
int n, m;
vector<int> G[35];
vector<int>::iterator it;
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", str);
  for (int i = 0; i < n; i++) G[str[i] - 'a'].push_back(i);
  for (int i = 0; i < 26; i++) w[i] = i;
  while (m--) {
    scanf("%s%s", a, b);
    int x = a[0] - 'a';
    int y = b[0] - 'a';
    int t = w[x];
    w[x] = w[y];
    w[y] = t;
  }
  for (int i = 0; i < 26; i++) {
    if (w[i] == -1) continue;
    for (it = G[w[i]].begin(); it != G[w[i]].end(); it++) {
      s[*it] = i + 'a';
    }
  }
  printf("%s\n", s);
  return 0;
}
