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