#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  scanf("%lld", &n);
  scanf("%lld", &m);
  long long int i, j;
  string s;
  cin >> s;
  long long int arr[400], brr[400];
  for (i = 1; i <= 300; i++) {
    arr[i] = i;
    brr[i] = i;
  }
  while (m--) {
    char a, b;
    cin >> a >> b;
    long long int ind1 = brr[a];
    long long int ind2 = brr[b];
    arr[ind1] = b;
    arr[ind2] = a;
    brr[b] = ind1;
    brr[a] = ind2;
  }
  for (i = 0; i < (long long int)s.size(); i++) {
    s[i] = (char)arr[s[i]];
  }
  cout << s << "\n";
}
