#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::map;
using std::pair;
using std::string;
using std::swap;
using std::vector;
vector<vector<int> > v(26);
int main() {
  cin.tie(0);
  cout.tie(0);
  std::ios::sync_with_stdio(false);
  ;
  int i, j, k;
  int m, t, n;
  char a, b, c;
  int d;
  scanf("%d%d", &n, &m);
  vector<vector<int>*> vr(26);
  getchar();
  for (i = 0; i < (n); ++i) {
    c = (getchar() - 'a');
    v[c].push_back(i);
  }
  getchar();
  for (i = 0; i < (26); ++i) {
    vr[i] = &v[i];
  }
  for (i = 0; i < (m); ++i) {
    a = getchar();
    getchar();
    b = getchar();
    getchar();
    swap(vr[a - 'a'], vr[b - 'a']);
  }
  vector<char> out(n);
  for (i = 0; i < (26); ++i) {
    vector<int>& ref = *vr[i];
    int temp_size = ref.size();
    for (j = 0; j < (temp_size); ++j) out[ref[j]] = i + 'a';
  }
  for (i = 0; i < (n); ++i) putchar(out[i]);
  return 0;
}
