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