#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  string s;
  char x, y;
  cin >> s;
  char ch[26];
  for (long long int i = 0; i < 26; i++) {
    ch[i] = i + 'a';
  }
  for (long long int i = 0; i < m; i++) {
    cin >> x >> y;
    for (long long int j = 0; j < 26; j++) {
      if (x == ch[j]) {
        ch[j] = y;
      } else if (y == ch[j]) {
        ch[j] = x;
      }
    }
  }
  for (long long int i = 0; i < s.size(); i++) {
    cout << ch[s[i] - 'a'];
  }
  return 0;
}
