#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  string x;
  char c[26];
  for (int i = 0; i < 26; i++) {
    c[i] = i + 'a';
  }
  cin >> n >> m >> x;
  char a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    for (int i = 0; i < 26; i++) {
      if (c[i] == a) {
        c[i] = b;
      } else if (c[i] == b)
        c[i] = a;
    }
  }
  int d;
  for (int i = 0; i < n; i++) {
    d = x[i] - 97;
    cout << c[d];
  }
}
