#include <bits/stdc++.h>
using namespace std;
char s[1000], str[1000], temp[100];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  scanf("%s", s + 1);
  for (int i = 1; i <= m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    scanf("%s", str);
    scanf("%s", temp);
    char x1 = str[0];
    char x2 = temp[0];
    for (int j = l; j <= r; j++) {
      if (s[j] == x1) s[j] = x2;
    }
  }
  printf("%s\n", s + 1);
}
