#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[200010];
int val[500];
int main() {
  cin >> n >> m;
  cin >> (s + 1);
  for (int i = 'a'; i <= 'z'; i++) val[i] = i;
  while (m--) {
    char x, y;
    cin >> x >> y;
    for (int i = 'a'; i <= 'z'; i++) {
      if (val[i] == x)
        val[i] = y;
      else if (val[i] == y)
        val[i] = x;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << (char)val[s[i]];
  }
  return 0;
}
