#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  char s[n + 1];
  scanf("%s", s);
  int l, r, i;
  char c1, c2;
  for (i = 0; i < m; i++) {
    scanf("%d %d ", &l, &r);
    scanf("%c %c", &c1, &c2);
    for (l = l - 1; l < r; l++) {
      if (s[l] == c1) s[l] = c2;
    }
  }
  printf("%s\n", s);
}
