#include <bits/stdc++.h>
using namespace std;
char x, y;
int main() {
  long int n, m, i, j;
  int par[200];
  bool visited[200];
  string str;
  cin >> n >> m;
  cin >> str;
  for (i = 97; i <= 122; i++) par[i] = i;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    for (j = 97; j <= 122; j++) {
      if (par[j] == (int)x)
        par[j] = y;
      else if (par[j] == (int)y)
        par[j] = x;
    }
  }
  for (i = 0; i < n; i++) {
    printf("%c", char(par[str[i]]));
  }
  cout << endl;
  return 0;
}
