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