#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
vector<vector<int>> v;
vector<pair<int, char>> p;
int n, m;
string second;
char a, b, x = 'a';
int main() {
  cin >> n >> m >> second;
  v.resize(28);
  for (int i = 0; i < n; ++i) {
    v[second[i] - 'a'].push_back(i);
  }
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    swap(v[a - 'a'], v[b - 'a']);
  }
  for (int i = 0; i < 28; ++i) {
    for (int t = 0; t < v[i].size(); ++t) {
      p.push_back({v[i][t], x});
    }
    x++;
  }
  sort(p.begin(), p.end());
  for (int i = 0; i < n; ++i) {
    cout << p[i].second;
  }
  return 0;
}
