#include <bits/stdc++.h>
using namespace std;
pair<char, char> A[200005];
map<char, int> B;
map<char, char> K;
int main() {
  int n, p;
  cin >> n >> p;
  string s;
  cin >> s;
  for (int i = 0; i < p; ++i) {
    cin >> A[i].first >> A[i].second;
    if (!B.count(A[i].first)) B[A[i].first] = i;
    if (!B.count(A[i].second)) B[A[i].second] = i;
  }
  for (auto x : B) {
    int idx = x.second;
    char c = x.first;
    for (int i = x.second; i < p; ++i) {
      if (A[i].first == c) {
        c = A[i].second;
      } else if (A[i].second == c) {
        c = A[i].first;
      }
    }
    K[x.first] = c;
  }
  for (int i = 0; i < n; ++i) {
    if (K.count(s[i])) s[i] = K[s[i]];
  }
  cout << s;
  return 0;
}
