#include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
const long long llinf = 9223372036854775807LL;
char mgetchar() {
  while (true) {
    char ch = getchar();
    if (ch < 'a' || ch > 'z') continue;
    return ch;
  }
}
char buffer[10];
int main() {
  string s;
  int n, m;
  cin >> n >> m;
  vector<pair<char, char> > v;
  char mas[200];
  for (int i = 0; i < 200; i++) {
    mas[i] = char(i);
  }
  cin >> s;
  for (int i = 0; i < m; i++) {
    char a, b;
    scanf("%s", buffer);
    a = buffer[0];
    scanf("%s", buffer);
    b = buffer[0];
    v.push_back(make_pair(a, b));
  }
  bool f = 0;
  for (int i = 0; i < m; i++) {
    f = 0;
    for (int j = 'a'; j <= 'z'; j++) {
      for (int k = 'a'; k <= 'z'; k++) {
        if (mas[j] == v[i].first && mas[k] == v[i].second) {
          swap(mas[j], mas[k]);
          f = 1;
          break;
        }
      }
      if (f == 1) break;
    }
  }
  for (int i = 0; i < n; i++) {
    s[i] = mas[s[i]];
  }
  cout << s << endl;
  return 0;
}
