#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  string str;
  cin >> str;
  long long int arr[26] = {0};
  for (long long int i = 0; i < 26; i++) arr[i] = i;
  while (m--) {
    char x, y;
    cin >> x >> y;
    if (x != y) {
      for (long long int i = 0; i < 26; i++) {
        if (arr[i] == x - 'a') {
          arr[i] = y - 'a';
        } else if (arr[i] == y - 'a') {
          arr[i] = x - 'a';
        }
      }
    }
  }
  for (long long int i = 0; i < n; i++) {
    char c = arr[str[i] - 'a'] + 'a';
    cout << c;
  }
}
