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