#include <bits/stdc++.h>
using namespace std;
int len, m;
char x, y;
string s1;
int A[150];
int points[1 << 21];
int main() {
  scanf("%d %d", &len, &m);
  cin >> s1;
  for (int i = 'a'; i <= 'z'; i++) A[(int)i] = i;
  while (m--) {
    cin >> x >> y;
    for (int i = 'a'; i <= 'z'; i++) {
      if (A[i] == x)
        A[i] = y;
      else if (A[i] == y)
        A[i] = x;
    }
  }
  for (int i = 0; i < len; i++) printf("%c", A[s1[i]]);
  return 0;
}
