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