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