#include <bits/stdc++.h>
int a[26];
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  for (int i = 0; i < 26; i++) {
    a[i] = i;
  }
  string s;
  cin >> s;
  char ch1, ch2;
  for (int i = 0; i < k; i++) {
    cin >> ch1 >> ch2;
    for (int j = 0; j < 26; j++) {
      if (a[j] == ch1 - 'a')
        a[j] = ch2 - 'a';
      else {
        if (a[j] == ch2 - 'a') a[j] = ch1 - 'a';
      }
    }
  }
  string ans = "";
  for (int i = 0; i < n; i++) {
    ans += (char)(a[s[i] - 'a'] + 'a');
  }
  cout << ans;
}
