#include <bits/stdc++.h>
using namespace std;
char a[200005];
char alpha[26];
int main() {
  int n, k;
  cin >> n >> k;
  scanf("%s", a);
  int len = strlen(a);
  int i, j;
  for (j = 0; j < 26; j++) alpha[j] = j + 'a';
  for (i = 0; i < k; i++) {
    char x, y;
    cin >> x >> y;
    for (j = 0; j < 26; j++) {
      if (alpha[j] == x)
        alpha[j] = y;
      else if (alpha[j] == y)
        alpha[j] = x;
    }
  }
  for (i = 0; i < len; i++) printf("%c", alpha[a[i] - 'a']);
  return 0;
}
