#include <bits/stdc++.h>
using namespace std;
char buf[500];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  scanf("%s", &buf);
  for (int i = 1; i <= m; i++) {
    int l, r;
    char buf1[5], buf2[5];
    scanf("%d%d%s%s", &l, &r, &buf1, &buf2);
    l--, r--;
    for (int j = l; j <= r; j++) {
      if (buf[j] == buf1[0]) {
        buf[j] = buf2[0];
      }
    }
  }
  printf("%s", buf);
}
