#include <bits/stdc++.h>
using namespace std;
void imprimirVector(vector<int> v) {
  if (!v.empty()) {
    int p = v.size();
    cout << "[";
    for (int i = 0; i < (int)(p - 1); i++) cout << v[i] << ",";
    cout << v[p - 1] << "]" << endl;
  } else
    cout << "[]" << endl;
}
int toNumber(string s) {
  int Number;
  if (!(istringstream(s) >> Number)) Number = 0;
  return Number;
}
string toString(int number) {
  ostringstream ostr;
  ostr << number;
  return ostr.str();
}
int main() {
  ios_base::sync_with_stdio(0);
  long long n, m;
  string s;
  cin >> n >> m >> s;
  map<char, char> va;
  map<char, char> viene;
  for (int i = 0; i < (int)(26); i++) {
    va['a' + i] = 'a' + i;
    viene['a' + i] = 'a' + i;
  }
  for (int i = 0; i < (int)(m); i++) {
    char x, y;
    cin >> x >> y;
    va[viene[x]] = y;
    va[viene[y]] = x;
    char cavegol = viene[y];
    char pity = viene[x];
    viene[y] = pity;
    viene[x] = cavegol;
  }
  for (int i = 0; i < (int)(n); i++) s[i] = va[s[i]];
  cout << s << endl;
  return 0;
}
