#include <bits/stdc++.h>
using namespace std;
char ch[26];
void store() {
  char c = 'a';
  for (int i = 0; i < 26; i++) {
    ch[i] = c++;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  store();
  for (int i = 0; i < m; i++) {
    char c1, c2;
    cin >> c1 >> c2;
    for (int i = 0; i < 26; i++) {
      if (ch[i] == c1)
        ch[i] = c2;
      else if (ch[i] == c2)
        ch[i] = c1;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ch[s[i] - 97];
  }
}
