#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  char x, y;
  string s;
  char c[26];
  for (int i = 0; i < 26; i++) {
    c[i] = i + 'a';
  }
  cin >> s;
  for (int i = 0; i < b; i++) {
    cin >> x >> y;
    for (int i = 0; i < 26; i++) {
      if (c[i] == x)
        c[i] = y;
      else if (c[i] == y)
        c[i] = x;
    }
  }
  for (int i = 0; i < a; i++) {
    cout << c[s[i] - 'a'];
  }
  return 0;
}
