#include <bits/stdc++.h>
using namespace std;
map<char, char> mp, mp1;
int main() {
  long long m, n, b, c, d, i, j, k, z, l, q, r;
  string s, s1, s2, s3, s4;
  long long cnt = 0, ans = 0, sum = 0;
  cin >> n >> m >> s;
  char x, y;
  set<char> st;
  for (long long i = 0; i < s.size(); i++) {
    mp[s[i]] = 1;
    st.insert(s[i]);
  }
  for (auto it : st) s1 += it;
  vector<char> v;
  for (auto it : st) v.push_back(it);
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    cnt = -1;
    if (mp[x] > 0 or mp[y] > 0) {
      for (long long j = 0; j < v.size(); j++) mp[v[j]] = 0;
      for (long long j = 0; j < v.size(); j++) {
        if (v[j] == x)
          v[j] = y;
        else if (v[j] == y)
          v[j] = x;
      }
    }
    for (long long j = 0; j < v.size(); j++) mp[v[j]] = 1;
  }
  for (long long i = 0; i < v.size(); i++) mp1[s1[i]] = v[i];
  for (long long i = 0; i < n; i++) s[i] = mp1[s[i]];
  cout << s;
  cout << "\n";
  return 0;
}
