#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[101];
  int n, m;
  scanf("%d%d", &n, &m);
  cin >> s;
  for (int i = 0; i < m; i++) {
    int l, r;
    char c1, c2;
    scanf("%d %d %c %c", &l, &r, &c1, &c2);
    for (int j = l - 1; j < r; j++) {
      if (s[j] == c1) s[j] = c2;
    }
  }
  cout << s;
  return 0;
}
