#include <bits/stdc++.h>
using namespace std;
const int N = 200051;
int d[N];
char c[N];
int main() {
  int n, m;
  while (cin >> n >> m) {
    cin >> c;
    int x[40];
    for (int i = 0; i < 26; i++) {
      x[i] = i;
    }
    char p, q;
    for (int i = 0; i < m; i++) {
      cin >> p >> q;
      for (int j = 0; j < 26; j++) {
        if (x[j] == p - 'a') {
          x[j] = q - 'a';
        } else if (x[j] == q - 'a') {
          x[j] = p - 'a';
        }
      }
    }
    for (int i = 0; i < n; i++) {
      c[i] = x[c[i] - 'a'] + 'a';
    }
    cout << c << endl;
  }
  return 0;
}
