#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
char _;
void scana() {}
template <class T, class... A>
void scana(T& t, A&... a) {
  do {
    while ((t = getchar()) < '0')
      ;
    for (t -= '0'; '0' <= (_ = getchar()); t = (t << 3) + (t << 1) + _ - '0')
      ;
  } while (0);
  scana(a...);
}
using namespace std;
int n, m;
string second;
char a, b;
map<char, char> mep;
int main() {
  cin >> n >> m;
  for (int i = 0; i < 26; ++i) {
    mep[char('a' + i)] = char('a' + i);
  }
  cin >> second;
  while (m--) {
    cin >> a >> b;
    for (int i = 0; i < 26; ++i) {
      if (mep[char('a' + i)] == a) {
        mep[char('a' + i)] = b;
      } else if (mep[char('a' + i)] == b) {
        mep[char('a' + i)] = a;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << mep[second[i]];
  }
  return 0;
}
