#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  string ans;
  string check = "abcdefghijklmnopqrstuvwxyz";
  while (k--) {
    char x, y;
    cin >> x >> y;
    swap(check[check.find(x)], check[check.find(y)]);
  }
  for (auto i : s) {
    cout << check[i - 'a'];
  }
}
