#include <bits/stdc++.h>
using namespace std;
int _I() {
  int x;
  scanf("%d", &x);
  return x;
}
struct node {
  int a, c, pr;
  node(){};
  node(int x, int y, int z) {
    a = x;
    c = y;
    pr = z;
  }
  bool operator<(const node &R) const {
    if (c == R.c) {
      if (pr == R.pr) {
        if (pr == 0) return a < R.a;
        return a > R.a;
      }
      return pr > R.pr;
    }
    return c < R.c;
  }
};
int dig(int n) {
  int sum = 0;
  while (n) {
    sum += (n % 10);
    n /= 10;
  }
  return sum;
}
char mp[200];
void solve() {
  int n = _I();
  int q = _I();
  string s;
  cin >> s;
  for (int i = 'a'; i <= 'z'; i++) mp[i] = i;
  while (q--) {
    string a, b;
    cin >> a >> b;
    int cnt = 0;
    for (char i = 'a'; i <= 'z'; i++) {
      if (mp[i] == a[0]) {
        mp[i] = b[0];
        cnt++;
      } else if (mp[i] == b[0]) {
        mp[i] = a[0];
        cnt++;
      }
      if (cnt == 2) break;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << mp[s[i]];
  }
  printf("\n");
}
int main() {
  solve();
  return 0;
}
