#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[100010];
int main() {
  cin >> n >> m;
  scanf("%s", s + 1);
  while (m--) {
    int l, r;
    cin >> l >> r;
    char a[2], b[2];
    scanf("%s%s", a, b);
    for (int i = l; i <= r; i++)
      if (s[i] == a[0]) s[i] = b[0];
  }
  printf("%s", s + 1);
  return 0;
}
