#include <bits/stdc++.h>
long n, m, i, j;
char x, y, q[100];
using namespace std;
int main() {
  cin >> n >> m;
  char a[n];
  cin >> a;
  for (i = 1; i <= 26; i++) q[i] = 'a' + i - 1;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    for (j = 1; j <= 26; j++)
      if (q[j] == x)
        q[j] = y;
      else if (q[j] == y)
        q[j] = x;
  }
  for (i = 0; i < n; i++) cout << q[(int)(a[i] - 'a' + 1)];
  cout << endl;
}
