#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1000000007;
char ch[50];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  for (int i = 0; i < 26; i++) {
    ch[i] = i + 'a';
  }
  while (m--) {
    char x, y;
    cin >> x >> y;
    for (int j = 0; j < 26; j++) {
      if (ch[j] == x) {
        ch[j] = y;
      } else if (ch[j] == y) {
        ch[j] = x;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ch[s[i] - 'a'];
  }
}
