#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int SIZE = 301;
const int MSIZE = 10002000;
vector<char> mp[SIZE];
map<char, char> mark;
bool find(char x) {
  if (mark.find(x) == mark.end() || mark[x] == -1) return 0;
  return 1;
}
int main() {
  int n, m;
  string line;
  char x, y;
  while (cin >> n >> m) {
    cin >> line;
    mark.clear();
    for (int i = 'a'; i <= 'z'; i++) mp[i].clear();
    for (int i = 0; i < m; i++) {
      cin >> x >> y;
      if (x == y) continue;
      if (find(x) == 0) {
        if (find(y) == 0) {
          mp[x].push_back(y);
          mark[y] = x;
          mp[y].push_back(x);
          mark[x] = y;
        } else {
          mp[mark[y]].push_back(x);
          mark[x] = mark[y];
          mp[x].push_back(y);
          mark[y] = x;
        }
      } else {
        if (find(y) == 0) {
          mp[mark[x]].push_back(y);
          mark[y] = mark[x];
          mp[y].push_back(x);
          mark[x] = y;
        } else {
          char prex = mark[x];
          char prey = mark[y];
          mp[prex].push_back(y);
          mp[prey].push_back(x);
          mark[x] = prey;
          mark[y] = prex;
        }
      }
    }
    for (int i = 0; i < line.size(); i++) {
      char x = line[i];
      int sz = mp[x].size();
      if (sz != 0) line[i] = mp[x][sz - 1];
    }
    cout << line << endl;
  }
}
