#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[101], c1[101], c2[101];
  int n, m, l[101], r[101];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> c1[i] >> c2[i];
  }
  for (int i = 0; i < m; i++) {
    for (int j = l[i] - 1; j <= r[i] - 1; j++) {
      if (a[j] == c1[i]) {
        a[j] = c2[i];
      }
    }
  }
  a[n] = '\0';
  cout << a;
}
