#include <bits/stdc++.h>
using namespace std;
void print(vector<int> &v);
void print(vector<vector<int>> &vv);
inline void change(string &s, char a, char b) {
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == a)
      s[i] = b;
    else if (s[i] == b)
      s[i] = a;
  }
  return;
}
inline void buildmap(map<char, vector<int>> &mm, string &s) {
  int n = s.size();
  for (int i = 0; i < n; i++) mm[s[i]].push_back(i);
  return;
}
inline void updateMap(map<char, vector<int>> &mm, char a, char b) {
  mm[a].swap(mm[b]);
}
int main() {
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  map<char, vector<int>> mm;
  buildmap(mm, s);
  for (int i = 0; i < m; i++) {
    char a, b;
    cin >> a >> b;
    if (a != b) updateMap(mm, a, b);
  }
  vector<char> res(n);
  for (auto it : mm) {
    for (auto jt : it.second) {
      res[jt] = it.first;
    }
  }
  for (auto it : res) cout << it;
  cout << endl;
  return 0;
}
void print(vector<int> &v) {
  for (auto it : v) cout << it << " ";
  cout << endl;
}
void print(vector<vector<int>> &vv) {
  for (auto it : vv) {
    for (auto jt : it) cout << jt << " ";
    cout << endl;
  }
}
