#include <bits/stdc++.h>
using namespace std;
struct node {
  char x;
  vector<int> index;
};
int main() {
  int n, m;
  cin >> n >> m;
  node* a[26];
  for (int i = 0; i < 26; i++) {
    a[i] = new node();
    a[i]->x = (char)(i + 'a');
  }
  string x;
  cin >> x;
  for (int i = 0; i < n; i++) {
    int z = x[i] - 'a';
    a[z]->index.push_back(i);
  }
  for (int i = 0; i < m; i++) {
    char p, q;
    cin >> p >> q;
    int m, n;
    m = p - 'a';
    n = q - 'a';
    node* temp = a[m];
    a[m] = a[n];
    a[n] = temp;
  }
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < a[i]->index.size(); j++) {
      x[a[i]->index[j]] = (char)(i + 'a');
    }
  }
  cout << x << endl;
}
