#include <bits/stdc++.h>
using namespace std;
string str;
int ara[28];
int main() {
  int n, m, x, y, i, j;
  char a, b;
  cin >> n >> m >> str;
  for (i = 0; i < 26; i++) ara[i] = i;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    x = a - 97;
    y = b - 97;
    for (j = 0; j < 26; j++) {
      if (ara[j] == x)
        ara[j] = y;
      else if (ara[j] == y)
        ara[j] = x;
    }
  }
  for (i = 0; i < n; i++) {
    x = str[i] - 97;
    x = ara[x];
    str[i] = x + 97;
    cout << str[i];
  }
  cout << endl;
  return 0;
}
