#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  char arr[26];
  map<int, int> mmap;
  for (int i = 0; i < 26; i++) {
    mmap[i] = i;
    arr[i] = i;
  }
  for (int i = 0; i < m; i++) {
    char pr, nx;
    cin >> pr >> nx;
    arr[mmap[pr - 'a']] = nx - 'a';
    arr[mmap[nx - 'a']] = pr - 'a';
    int temp = mmap[nx - 'a'];
    mmap[nx - 'a'] = mmap[pr - 'a'];
    mmap[pr - 'a'] = temp;
    for (int i = 0; i < 26; i++) {
      if (false)
        cout << (char)('a' + i) << " -> " << (char)(arr[i] + 'a') << endl;
    }
  }
  string ans = "";
  for (int i = 0; i < s.length(); i++) {
    ans += (char)(arr[s[i] - 'a'] + 'a');
  }
  cout << ans << endl;
}
int main() { solve(); }
