#include <bits/stdc++.h>
using namespace std;
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(long long N, int pos) { return (bool)(N & (1LL << pos)); }
int n, m, l, r;
string s;
char c1, c2;
int main() {
  cin >> n >> m;
  cin >> s;
  for (int i = 1; i <= m; i++) {
    cin >> l >> r >> c1 >> c2;
    l--, r--;
    for (int j = l; j <= r; j++) {
      if (s[j] == c1) s[j] = c2;
    }
  }
  cout << s << endl;
  return 0;
}
