#include <bits/stdc++.h>
using namespace std;
string s;
char zh[125], ch, sw;
int n, m;
int main() {
  cin >> n >> m >> s;
  for (int i = 97; i <= 122; i += 1) {
    zh[i] = i;
  }
  for (int i = 1; i <= m; i += 1) {
    cin >> ch >> sw;
    for (int j = 97; j <= 122; j += 1) {
      if (zh[j] == ch) {
        zh[j] = sw;
      } else {
        if (zh[j] == sw) {
          zh[j] = ch;
        }
      }
    }
  }
  for (int i = 0; i <= n - 1; i += 1) {
    cout << zh[s[i]];
  }
  return 0;
}
