#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  char str[26];
  for (int j = 0; j < 26; j++) str[j] = 'a' + j;
  for (int i = 0; i < m; i++) {
    char a, b;
    cin >> a >> b;
    int pos1 = 0, pos2 = 0;
    for (int k = 0; k < 26; k++) {
      if (str[k] == a) pos1 = k;
      if (str[k] == b) pos2 = k;
    }
    swap(str[pos1], str[pos2]);
  }
  for (int kk = 0; kk < n; kk++) {
    s[kk] = str[s[kk] - 'a'];
  }
  cout << s << endl;
  return 0;
}
