#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 0, m = 0;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<char> v(26, 0);
  for (int i = 0; i < 26; i++) v[i] = i + 'a';
  for (int i = 0; i < m; i++) {
    char a, b;
    cin >> a >> b;
    for (int j = 0; j < 26; j++) {
      if (v[j] == a)
        v[j] = b;
      else if (v[j] == b)
        v[j] = a;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << v[s[i] - 'a'];
  }
  cout << endl;
  return 0;
}
