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