#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string name;
  cin >> name;
  string subst = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < m; ++i) {
    char a, b;
    cin >> a >> b;
    assert(a >= 'a' && a <= 'z');
    assert(b >= 'a' && b <= 'z');
    if (a == b) continue;
    string newsubst(subst);
    for (int i = 0; i < 26; ++i) {
      if (subst[i] == a) newsubst[i] = b;
      if (subst[i] == b) newsubst[i] = a;
    }
    subst.swap(newsubst);
  }
  for (int i = 0, e = name.size(); i < e; ++i) {
    name[i] = subst[name[i] - 'a'];
  }
  cout << name << "\n";
  return 0;
}
