#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  string str;
  cin >> n >> m;
  cin >> str;
  vector<char> make_pair;
  for (char i = 'a'; i <= 'z'; i++) {
    make_pair.push_back(i);
  }
  char a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    for (char i = 'a'; i <= 'z'; i++) {
      if (make_pair[i - 'a'] == a) {
        make_pair[i - 'a'] = b;
      } else if (make_pair[i - 'a'] == b) {
        make_pair[i - 'a'] = a;
      }
    }
  }
  for (int i = 0; i < str.size(); i++) {
    str[i] = make_pair[str[i] - 'a'];
  }
  cout << str << endl;
  return 0;
}
