#include <bits/stdc++.h>
using namespace std;
char change[27], a, b;
char str[200010];
int n, m, flag;
int main() {
  scanf("%d%d%*c", &n, &m);
  scanf("%s%*c", str);
  for (int i = 1; i <= 26; i++) change[i] = i + 96;
  for (int i = 1; i <= m; i++) {
    scanf("%c %c%*c", &a, &b);
    flag = 1;
    for (int i = 1; i <= 26; i++)
      if (change[i] == a) {
        flag = 0;
        change[i] = b - 32;
      }
    for (int i = 1; i <= 26; i++)
      if (change[i] == b) {
        flag = 0;
        change[i] = a;
      } else {
        if (change[i] <= 'Z' && change[i] >= 'A') change[i] += 32;
      }
  }
  for (int i = 0; i < n; i++) str[i] = change[str[i] - 96];
  printf("%s\n", str);
}
