#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
const int M = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  char s[n + 10];
  cin >> s;
  while (m--) {
    int l, r;
    char x, y;
    cin >> l >> r >> x >> y;
    for (int i = l - 1; i < r; i++)
      if (s[i] == x) s[i] = y;
  }
  cout << s << '\n';
}
