#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  while (m--) {
    int l, r;
    char c1, c2;
    cin >> l >> r >> c1 >> c2;
    for (int i = l; i <= r; i++) {
      if (s[i - 1] == c1) {
        s[i - 1] = c2;
      }
    }
  }
  cout << s;
  return 0;
}
