#include <bits/stdc++.h>
using namespace std;
int main() {
  char alph[1000];
  char brand[200001];
  char a, b;
  int n, m;
  for (int i = 'a'; i <= 'z'; i++) alph[i] = i;
  cin >> n >> m;
  scanf("%s", brand);
  for (int d = 0; d < m; d++) {
    getchar();
    a = getchar();
    getchar();
    b = getchar();
    if (a != b) {
      for (int i = 'a'; i <= 'z'; i++) {
        if (alph[i] == a) {
          alph[i] = b;
        } else if (alph[i] == b) {
          alph[i] = a;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    putchar(alph[brand[i]]);
  }
  return 0;
}
