#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  char inp[105];
  scanf("%d%d", &n, &m);
  scanf("%s", inp);
  int xb, x2, xx, xxx;
  for (xb = 0; xb < m; ++xb) {
    int a, b, c1, c2;
    scanf("%d %d", &a, &b);
    c1 = getchar();
    while (c1 == ' ' || c1 == '\n') c1 = getchar();
    c2 = getchar();
    while (c2 == ' ' || c2 == '\n') c2 = getchar();
    for (x2 = a - 1; x2 < b; ++x2) {
      if (inp[x2] == c1) inp[x2] = c2;
    }
  }
  printf("%s", inp);
  return 0;
}
