#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    char c[26];
    for (int i = 0; i < 26; i++) {
      c[i] = i + 'a';
    }
    for (int j = 0; j < m; j++) {
      char l, r;
      cin >> l >> r;
      for (int i = 0; i < 26; i++) {
        if (c[i] == l) {
          c[i] = r;
        } else if (c[i] == r) {
          c[i] = l;
        }
      }
    }
    for (int i = 0; i < s.size(); i++) {
      char ss = s[i];
      cout << c[ss - 'a'];
    }
  }
}
