#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  string s;
  cin >> s;
  while (m--) {
    int a1, a2;
    char a3, a4;
    scanf("%d %d %c %c", &a1, &a2, &a3, &a4);
    a1--;
    a2--;
    while (a1 <= a2) {
      if (s[a1] == a3) s[a1] = a4;
      a1++;
    }
  }
  cout << s << '\n';
  return 0;
}
