#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000000 + 7;
long long pow2(int step) {
  if (step == 0) return 1;
  if (step == 1) return 2;
  long long a = pow2(step / 2) % MOD;
  a = (a * a) % MOD;
  a = a * pow2(step % 2) % MOD;
  return a % MOD;
}
int main() {
  int n, m;
  string s;
  cin >> n >> m;
  cin >> s;
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    char a, b;
    cin >> a >> b;
    for (int j = l - 1; j < r; j++)
      if (s[j] == a) s[j] = b;
  }
  cout << s << endl;
}
