#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int x, y;
  cin >> x >> y;
  string s;
  cin >> s;
  map<char, vector<int> > mop;
  for (int i = 0; i < s.size(); i++) mop[s[i]].push_back(i);
  while (y--) {
    char a, b;
    cin >> a >> b;
    swap(mop[a], mop[b]);
  }
  vector<pair<int, char> > ans;
  for (__typeof((mop).begin()) it = (mop).begin(); it != (mop).end(); it++) {
    for (__typeof((it->second).begin()) it2 = (it->second).begin();
         it2 != (it->second).end(); it2++)
      ans.push_back(make_pair(*it2, it->first));
  }
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) cout << ans[i].second;
  return 0;
}
