#include <bits/stdc++.h>
using namespace std;
int main() {
  char ma[200];
  string s;
  int n, m;
  cin >> n >> m;
  for (char i = 'a'; i <= 'z'; i++) {
    ma[i] = i;
  }
  cin >> s;
  char u, v;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    char temp = ma[u];
    for (char c = 'a'; c <= 'z'; c++) {
      temp = ma[c];
      if (temp == u) ma[c] = v;
      if (temp == v) ma[c] = u;
    }
  }
  for (int i = 0; i < s.size(); i++) cout << ma[s[i]];
}
