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