#include <bits/stdc++.h>
using namespace std;
string s;
char a[200123];
int i, j, k, m, n;
vector<int> q[255];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  cin >> s;
  for (i = 0; i < s.size(); ++i) q[s[i]].push_back(i);
  while (m--) {
    char cx, cy;
    cin >> cx >> cy;
    q[cy].swap(q[cx]);
  }
  for (char i = 'a'; i <= 'z'; ++i)
    for (j = 0; j < q[i].size(); ++j) a[q[i][j]] = i;
  for (int i = 0; i < n; ++i) cout << a[i];
  return 0;
}
