#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int len, m;
  cin >> len >> m;
  string x, a = "abcdefghijklmnopqrstuvwxyz";
  cin >> x;
  for (int i = 1; i <= m; i++) {
    char p, q;
    cin >> p >> q;
    for (int i = 0; i <= 25; i++) {
      if (a[i] == p)
        a[i] = q;
      else if (a[i] == q)
        a[i] = p;
    }
  }
  for (int i = 0; i <= len - 1; i++) {
    x[i] = a[x[i] - 'a'];
  }
  cout << x;
  return 0;
}
