#include <bits/stdc++.h>
int main() {
  int n, m;
  std::cin >> n >> m;
  char indices[26];
  std::vector<std::list<int> > positions(26);
  for (int i = 0; i < 26; ++i) {
    indices[i] = i;
  }
  for (int i = 0; i < n; ++i) {
    char temp;
    std::cin >> temp;
    positions[temp - 'a'].push_back(i);
  }
  for (int i = 0; i < m; ++i) {
    char c1, c2;
    std::cin >> c1 >> c2;
    std::swap(indices[c1 - 'a'], indices[c2 - 'a']);
  }
  char *output = new char[n];
  for (int i = 0; i < 26; ++i) {
    for (std::list<int>::iterator it = positions[indices[i]].begin();
         it != positions[indices[i]].end(); ++it) {
      output[*it] = i + 'a';
    }
  }
  for (int i = 0; i < n; ++i) {
    std::cout << output[i];
  }
  std::cout << '\n';
}
