#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  string s;
  char b[26];
  char x, y;
  for (char sym = 'a'; sym <= 'z'; sym++) {
    b[sym - 'a'] = sym;
  }
  cin >> n >> m;
  cin >> s;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    for (int j = 0; j < 26; j++)
      if (b[j] == x)
        b[j] = y;
      else if (b[j] == y)
        b[j] = x;
  }
  for (int i = 0; i < s.size(); i++) {
    cout << b[s[i] - 'a'];
  }
}
