#include <bits/stdc++.h>
using namespace std;
long long n, l, i, j;
char x, y;
string s;
int main() {
  char a[255] = {"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"};
  char b[255] = {"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"};
  cin >> l >> n;
  cin >> s;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    for (j = 0; j <= 80; j++) {
      if (a[j] == x)
        a[j] = y;
      else if (a[j] == y)
        a[j] = x;
    }
  }
  for (i = 0; i < s.size(); i++) {
    for (j = 0; j <= 80; j++) {
      if (s[i] == b[j]) {
        s[i] = a[j];
        break;
      }
    }
  }
  cout << s;
  return 0;
}
