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