#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  string s;
  char x, y, temp[256];
  for (int i = 'a'; i <= 'z'; i++) temp[i] = i;
  cin >> n >> m >> s;
  while (m--) {
    cin >> x >> y;
    for (int i = 'a'; i <= 'z'; i++) {
      if (temp[i] == x)
        temp[i] = y;
      else if (temp[i] == y)
        temp[i] = x;
    }
  }
  for (int i = 0; i < n; i++) s[i] = temp[s[i]];
  cout << s;
  return 0;
}
