#include <bits/stdc++.h>
using namespace std;
const int oo = 1000007;
char c[250000];
int main() {
  int n, m;
  cin >> n >> m;
  scanf("%s", c);
  string s = c;
  char b[30];
  for (int i = 0; i < 26; i++) b[i] = 'a' + i;
  map<char, char> mm;
  for (int i = 0; i < 26; i++) {
    mm[i + 'a'] = i + 'a';
  }
  map<char, char>::iterator it;
  for (int i = 0; i < m; i++) {
    char x, y;
    cin >> x >> y;
    for (it = mm.begin(); it != mm.end(); it++) {
      if ((*it).second == x)
        (*it).second = y;
      else if ((*it).second == y)
        (*it).second = x;
    }
  }
  for (it = mm.begin(); it != mm.end(); it++) {
    b[(*it).first - 'a'] = (*it).second;
  }
  for (int i = 0; i < n; i++) {
    s[i] = b[s[i] - 'a'];
  }
  cout << s;
  return 0;
}
