#include <bits/stdc++.h>
using namespace std;
const int MAX = (int)1e5 + 55;
const int INF = (int)1e9 + 77;
const int MOD = (int)1e9 + 7;
const double PI = 2 * acos(0.0);
const double EPS = 1e-7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  string s;
  cin >> n >> m >> s;
  for (int i = 0; i < m; ++i) {
    int l, r;
    char ch1, ch2;
    cin >> l >> r >> ch1 >> ch2;
    --l;
    --r;
    for (int j = l; j <= r; ++j) {
      if (s[j] == ch1) s[j] = ch2;
    }
  }
  cout << s << '\n';
  return 0;
}
