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