#include <bits/stdc++.h>
using namespace std;
const int MAX = 200010;
int n, m;
char s[MAX];
int vis[31];
int main() {
  int i, j, k;
  while (~scanf("%d%d", &n, &m)) {
    for (i = 0; i < 26; i++) vis[i] = i;
    scanf("%s", s);
    getchar();
    while (m--) {
      char c[11];
      gets(c);
      for (i = 0; i < 26; i++) {
        if (vis[i] == c[0] - 'a')
          vis[i] = c[2] - 'a';
        else if (vis[i] == c[2] - 'a')
          vis[i] = c[0] - 'a';
      }
    }
    for (i = 0; i < n; i++) {
      s[i] = vis[s[i] - 'a'] + 'a';
    }
    printf("%s\n", s);
  }
  return 0;
}
