#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5 + 7;
const int INF = (int)1e9;
long long b, c, d, cnt, e[(int)2e3 + 1][(int)2e3 + 1], cost[maxn], tout[maxn],
    mn = INF, mx = -INF;
long long cntc;
long long a;
pair<int, int> p[maxn];
bool u[40 * 40 + 7];
long long cl[maxn * 3];
char c1, c2, ch[26];
string second, t;
map<char, vector<int> > mp;
int main() {
  for (int i = 0; i < 26; ++i) {
    ch[i] = i + 'a';
  }
  cin >> a >> b >> second;
  for (int i = 1; i <= b; ++i) {
    cin >> c1 >> c2;
    for (int j = 0; j < 26; ++j) {
      if (ch[j] == c1) {
        ch[j] = c2;
      } else if (ch[j] == c2) {
        ch[j] = c1;
      }
    }
  }
  for (int i = 0; i < a; ++i) {
    cout << ch[second[i] - 'a'];
  }
  return 0;
  ;
}
