#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 9;
char s[MAXN];
map<char, char> mp;
int main(int argc, char const *argv[]) {
  int n, m;
  scanf("%d%d", &n, &m);
  scanf("%s", s);
  int present = 0;
  for (int i = 0; i < n; i++) {
    present |= (1 << (s[i] - 'a'));
  }
  for (char c = 'a'; c <= 'z'; c++)
    if (present & (1 << (c - 'a'))) {
      mp[c] = c;
    }
  char one, two;
  for (int i = 0; i < m; i++) {
    scanf(" %c %c", &one, &two);
    if (one == two) {
      continue;
    }
    for (auto &it : mp) {
      if (it.second == one)
        it.second = two;
      else if (it.second == two)
        it.second = one;
    }
  }
  for (int i = 0; i < n; i++)
    if (mp.count(s[i])) {
      s[i] = mp[s[i]];
    }
  puts(s);
  return 0;
}
