#include <bits/stdc++.h>
using namespace std;
char s[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
char str[200002];
int main() {
  ios::sync_with_stdio(0);
  long long int n, m;
  cin >> n >> m;
  cin >> str;
  char tmp, ch1, ch2;
  for (int i = 1; i <= m; i++) {
    cin >> ch1 >> ch2;
    for (int j = 0; j < 26; j++) {
      if (s[j] == ch1)
        s[j] = ch2;
      else if (s[j] == ch2)
        s[j] = ch1;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << s[(int)str[i] - 'a'];
  }
  cout << endl;
  return 0;
}
