#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, l, r;
  char c[2];
  cin >> m >> n;
  char a[m];
  for (int i = 0; i < (m); ++i) cin >> a[i];
  while (n) {
    cin >> l >> r;
    cin >> c[0] >> c[1];
    for (int i = l - 1; i < r; ++i)
      if (a[i] == c[0]) a[i] = c[1];
    --n;
  }
  for (int i = 0; i < (m); ++i) cout << a[i];
}
