#include <bits/stdc++.h>
using namespace std;
string s;
char ch[30];
bool ar[30];
int main() {
  long long n, r;
  cin >> n >> r;
  cin >> s;
  for (long long i = 0; i < 27; i++) {
    ch[i] = i;
  }
  char a, b;
  while (r--) {
    cin >> a >> b;
    for (long long i = 0; i < 27; i++) {
      if (ch[i] == b - 'a') {
        ch[i] = a - 'a';
        ar[i] = 1;
      }
      if (ch[i] == a - 'a' && ar[i] == 0) {
        ch[i] = b - 'a';
      }
      memset((ar), 0, sizeof((ar)));
    }
  }
  for (long long i = 0; i < s.size(); i++) {
    if (ch[s[i] - 'a'] != -1) s[i] = ch[s[i] - 'a'] + 'a';
  }
  cout << s << endl;
  return 0;
}
