#include <bits/stdc++.h>
using namespace std;
int main() {
  char buffer[200061];
  char buffer2[61];
  int n, m;
  char w1, w2;
  char dic['z' + 61];
  int dicpos['z' + 61];
  for (int i = 1; i <= 'z'; i++) {
    dic[i] = i;
    dicpos[i] = i;
  }
  scanf("%d %d ", &n, &m);
  scanf("%s ", buffer);
  while (m--) {
    gets(buffer2);
    sscanf(buffer2, "%c %c", &w1, &w2);
    dic[dicpos[w1]] = w2;
    dic[dicpos[w2]] = w1;
    int t = dicpos[w1];
    dicpos[w1] = dicpos[w2];
    dicpos[w2] = t;
  }
  for (int i = 0; i < n; i++) {
    putchar(dic[buffer[i]]);
  }
  putchar('\n');
}
