#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  char res[26], x, y;
  for (int i = 0; i < 26; i++) res[i] = 'a' + i;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    for (int j = 0; j < 26; j++) {
      if (res[j] == x)
        res[j] = y;
      else if (res[j] == y)
        res[j] = x;
    }
  }
  for (int i = 0; i < n; i++) cout << res[s[i] - 97];
  cout << endl;
}
