#include <bits/stdc++.h>
using namespace std;
set<int> ch[28];
char New[200002];
int main() {
  int n, m;
  cin >> n >> m;
  string a;
  cin >> a;
  for (int i = 0; i < n; i++) ch[a[i] - 'a'].insert(i);
  while (m--) {
    char b, c;
    cin >> b >> c;
    swap(ch[b - 'a'], ch[c - 'a']);
  }
  for (int i = 0; i < 27; i++)
    for (set<int>::iterator j = ch[i].begin(); j != ch[i].end(); j++)
      New[*j] = i + 'a';
  cout << New << endl;
}
