#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  int n, m;
  cin >> n >> m;
  cin >> s;
  while (m--) {
    int l, r;
    char c1, c2;
    cin >> l >> r >> c1 >> c2;
    l--, r--;
    for (int i = l; i <= r; i++) {
      if (s[i] == c1) s[i] = c2;
    }
  }
  cout << s;
  return 0;
}
