#include <bits/stdc++.h>
using namespace std;
string dw;
bool alfabet[26];
int main() {
  string name;
  int n, m;
  cin >> n >> m;
  cin >> name;
  for (int i = 0; i < name.size(); i++)
    if (!alfabet[name[i] - 'a']) {
      alfabet[name[i] - 'a'] = true;
      dw.push_back(name[i]);
    }
  string t = dw;
  char c1, c2;
  for (int i = 0; i < m; i++) {
    cin >> c1 >> c2;
    for (int j = 0; j < dw.size(); j++)
      if (dw[j] == c1)
        dw[j] = c2;
      else if (dw[j] == c2)
        dw[j] = c1;
  }
  char ans[26];
  for (int i = 0; i < 26; i++) {
    ans[i] = 'a' + i;
    for (int j = 0; j < t.size(); j++)
      if (t[j] == ('a' + i)) ans[i] = dw[j];
  }
  for (int i = 0; i < n; i++) cout << ans[name[i] - 'a'];
  return 0;
}
