#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 * 1e5 + 3;
int n, m;
char s[MAXN];
char d[256];
int main() {
  cin >> n >> m;
  for (int i = (int)'a'; i <= (int)'z'; ++i) d[i] = (char)i;
  cin >> s;
  for (int k = 0; k < m; ++k) {
    char u, v;
    cin >> u >> v;
    for (int i = 'a'; i <= 'z'; ++i) {
      if (d[i] == u)
        d[i] = v;
      else if (d[i] == v)
        d[i] = u;
    }
  }
  for (int i = 0; i < n; ++i) cout << d[(int)s[i]];
  return 0;
}
