#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const long long lloo = 1e18;
const int oo = 1e9;
char c[200100];
string s;
vector<int> vec[256];
char lab[256];
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  cin >> s;
  for (int j = 'a', _b = 'z'; j <= _b; j++) lab[j] = j;
  for (int i = 0; i < s.size(); i++) {
    vec[s[i]].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    char x, y;
    cin >> x >> y;
    char p;
    for (int j = 'a', _b = 'z'; j <= _b; j++)
      if (lab[j] == x) {
        p = j;
      }
    char q;
    for (int j = 'a', _b = 'z'; j <= _b; j++)
      if (lab[j] == y) {
        q = j;
      }
    swap(lab[p], lab[q]);
  }
  for (int j = 'a', _b = 'z'; j <= _b; j++) {
    for (int i = 0; i < vec[j].size(); i++) {
      int v = vec[j][i];
      s[v] = lab[j];
    }
  }
  cout << s << "\n";
}
