#include <bits/stdc++.h>
using namespace std;
char delta[26];
bool vis[26];
int main() {
  int n, m;
  string s;
  cin >> n >> m >> s;
  for (int i = 0; i < 26; i++) delta[i] = i + 'a';
  for (char x, y; m--;) {
    cin >> x >> y;
    for (int i = 0; i < 26; i++) vis[i] = 0;
    for (int i = 0; i < 26; i++) {
      if (delta[i] == x) {
        delta[i] = y;
        vis[i] = 1;
      }
    }
    for (int i = 0; i < 26; i++) {
      if (!vis[i] && delta[i] == y) {
        delta[i] = x;
        vis[i] = 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    s[i] = delta[s[i] - 'a'];
  }
  cout << s << endl;
}
