#include <bits/stdc++.h>
using namespace std;
char c[27];
int len, m;
void init() {
  for (int i = 1; i <= 26; i++) c[i] = 96 + i;
}
int main() {
  init();
  cin >> len >> m;
  string s;
  cin >> s;
  for (int i = 1; i <= m; i++) {
    string a, b;
    cin >> a >> b;
    int a1, b1;
    for (int i = 1; i <= 26; i++) {
      if (c[i] == a[0]) a1 = i;
      if (c[i] == b[0]) b1 = i;
    }
    swap(c[a1], c[b1]);
  }
  for (int i = 0; i < len; i++) {
    s[i] = c[s[i] - 96];
  }
  cout << s;
}
