#include <bits/stdc++.h>
using namespace std;
string s;
int n, m;
char q, w;
int main() {
  cin >> n >> m >> s;
  string s1 = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < m; i++) {
    cin >> q >> w;
    for (int j = 0; j < s1.size(); j++) {
      if (s1[j] == q)
        s1[j] = w;
      else if (s1[j] == w)
        s1[j] = q;
    }
  }
  for (int i = 0; i < n; i++) {
    s[i] = s1[s[i] - 'a'];
  }
  cout << s;
}
