#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  char s[n + 5];
  scanf("%s", s);
  vector<int>* vp[30];
  for (int i = 0; i <= 25; i++) vp[i] = new vector<int>();
  for (int i = 0; s[i]; i++) {
    int now = s[i] - 'a';
    vp[now]->push_back(i);
  }
  while (m--) {
    getchar();
    char x, y;
    scanf("%c %c", &x, &y);
    int id1 = x - 'a';
    int id2 = y - 'a';
    swap(vp[id1], vp[id2]);
  }
  for (int i = 0; i <= 25; i++) {
    for (vector<int>::iterator it = vp[i]->begin(); it != vp[i]->end(); it++) {
      s[*it] = i + 'a';
    }
  }
  printf("%s\n", s);
  return 0;
}
