#include <bits/stdc++.h>
using namespace std;
const long long N = 2e2 + 30, Mod = 1e9 + 7;
const long long SQ = 330;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  long long n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  while (m--) {
    long long l, r;
    char c1, c2;
    cin >> l >> r >> c1 >> c2;
    l--;
    r--;
    for (int i = l; i <= r; i++) {
      if (s[i] == c1) s[i] = c2;
    }
  }
  cout << s;
  return (0);
}
