#include <bits/stdc++.h>
using namespace std;
int change[250];
string str;
int main() {
  for (int i = 0; i <= 200; i++) change[i] = i;
  int n, m;
  cin >> n >> m;
  cin >> str;
  getchar();
  for (int i = 0; i < m; i++) {
    char a, b;
    cin >> a >> b;
    for (int j = 0; j <= 200; j++) {
      if (change[j] == a)
        change[j] = b;
      else if (change[j] == b)
        change[j] = a;
    }
  }
  for (int p = 0; p < n; p++) {
    str[p] = change[str[p]];
  }
  cout << str << endl;
}
