#include <bits/stdc++.h>
using namespace std;
char *st;
int main() {
  int n, m, i = 0, l, r;
  char a, b;
  scanf("%d%d", &n, &m);
  st = new char[n];
  getchar();
  while ((st[i] = getchar()) != '\n') ++i;
  st[i] = '\0';
  ++m;
  while (--m) {
    scanf("%d%d %c %c", &l, &r, &a, &b);
    for (i = l - 1; i < r; ++i) st[i] = st[i] == a ? b : st[i];
  }
  puts(st);
  return 0;
}
