#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  string a, b;
  string s;
  cin >> n >> m;
  cin >> s;
  map<char, char> ganti;
  for (char c = 'a'; c <= 'z'; ++c) ganti[c] = c;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    for (char c = 'a'; c <= 'z'; ++c) {
      if (ganti[c] == a[0])
        ganti[c] = b[0];
      else if (ganti[c] == b[0])
        ganti[c] = a[0];
    }
  }
  for (int i = 0; i < n; ++i) s[i] = ganti[s[i]];
  cout << s << '\n';
  return 0;
}
