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