#include <bits/stdc++.h>
using namespace std;
string s;
char s1, s2;
int n, m, r[26];
int main() {
  cin >> n >> m;
  cin >> s;
  for (int i = 0; i < 26; i++) r[i] = i + 97;
  for (int i = 0; i < m; i++) {
    cin >> s1 >> s2;
    for (int j = 0; j < 26; j++)
      if (r[j] == s1)
        r[j] = s2;
      else if (r[j] == s2)
        r[j] = s1;
  }
  for (int i = 0; i < n; i++) printf("%c", r[s[i] - 97]);
  return 0;
}
