#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  string s;
  cin >> s;
  char a, b;
  map<char, char> mymap;
  map<char, char>::iterator it;
  for (char i = 'a'; i <= 'z'; i++) mymap[i] = i;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    for (it = mymap.begin(); it != mymap.end(); it++) {
      if (it->second == a)
        mymap[it->first] = b;
      else if (it->second == b)
        mymap[it->first] = a;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << mymap[s[i]];
  }
  return 0;
}
