#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including stree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
//data structure (fenwick substitute)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define ull uint64_t
#define ll int64_t
//debugging snippets
#define Local freopen("input","r",stdin)
#define tr1(x) cerr << #x << ": " << x << endl;
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define tr3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define tr4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
struct Node {
int pre6[5];
int pre7[5];
};
Node stree[800000];
string S;
Node merge(const Node & a, const Node & b) {
Node n;
for (int i = 0; i < 5; ++i) {
n.pre6[i] = b.pre6[a.pre6[i]];
n.pre7[i] = b.pre7[a.pre7[i]];
}
return n;
}
void build(int nd, int l, int r) {
if (l == r) {
Node & n = stree[nd];
for (int i = 0; i < 4; ++i) {
n.pre6[i] = i + ("2016"[i] == S[l]);
n.pre7[i] = i + ("2017"[i] == S[l]);
}
n.pre6[4] = n.pre7[4] = 4;
} else {
int m = (l + r) / 2;
build(2 * nd + 1, l, m);
build(2 * nd + 2, m + 1, r);
stree[nd] = merge(stree[2 * nd + 1], stree[2 * nd + 2]);
}
}
Node qry(int nd, int l, int r, int ql, int qr) {
if (l == ql && r == qr) {
return stree[nd];
} else {
int m = (l + r) / 2;
if (qr <= m) return qry(2 * nd + 1, l, m, ql, qr);
if (ql > m) return qry(2 * nd + 2, m + 1, r, ql, qr);
Node q1 = qry(2 * nd + 1, l, m, ql, m);
Node q2 = qry(2 * nd + 2, m + 1, r, m + 1, qr);
return merge(q1, q2);
}
}
int main() {
Local; //local testing
int n, q;
cin >> n >> q;
cin >> S;
build(0, 0, n - 1);
for (int i = 1; i <= q; ++i) {
int a, b;
string qans;
cin >> a >> b >> qans;
a--;
b--;
Node r = qry(0, 0, n - 1, a, b);
string ans;
if (r.pre7[0] == 4 && r.pre6[0] < 4) ans = "yes";
else ans = "no";
string corr = ans == qans ? "correct" : "incorrect";
cout << ans << " " << qans << " " << corr << '\n';
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlIDxleHQvcGJfZHMvYXNzb2NfY29udGFpbmVyLmhwcD4gLy8gQ29tbW9uIGZpbGUKI2luY2x1ZGUgPGV4dC9wYl9kcy90cmVlX3BvbGljeS5ocHA+IC8vIEluY2x1ZGluZyBzdHJlZV9vcmRlcl9zdGF0aXN0aWNzX25vZGVfdXBkYXRlCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp1c2luZyBuYW1lc3BhY2UgX19nbnVfcGJkczsKCi8vZGF0YSBzdHJ1Y3R1cmUgKGZlbndpY2sgc3Vic3RpdHV0ZSkKdGVtcGxhdGUgPHR5cGVuYW1lIFQ+CnVzaW5nIG9yZGVyZWRfc2V0ID0gdHJlZTxULCBudWxsX3R5cGUsIGxlc3M8VD4sIHJiX3RyZWVfdGFnLCB0cmVlX29yZGVyX3N0YXRpc3RpY3Nfbm9kZV91cGRhdGU+OwoKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBlYiBlbXBsYWNlX2JhY2sKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBwaWkgcGFpcjxpbnQsIGludD4KI2RlZmluZSB2aSB2ZWN0b3I8aW50PgojZGVmaW5lIHBsbCBwYWlyPGxsLCBsbD4KI2RlZmluZSBmaSBmaXJzdAojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIHVsbCB1aW50NjRfdAojZGVmaW5lIGxsIGludDY0X3QKCi8vZGVidWdnaW5nIHNua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CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCA0OyArK2kpIHsKICAgICAgICAgICAgbi5wcmU2W2ldID0gaSArICgiMjAxNiJbaV0gPT0gU1tsXSk7CiAgICAgICAgICAgIG4ucHJlN1tpXSA9IGkgKyAoIjIwMTciW2ldID09IFNbbF0pOwogICAgICAgIH0KICAgICAgICBuLnByZTZbNF0gPSBuLnByZTdbNF0gPSA0OwogICAgfSBlbHNlIHsKICAgICAgICBpbnQgbSA9IChsICsgcikgLyAyOwogICAgICAgIGJ1aWxkKDIgKiBuZCArIDEsIGwsIG0pOwogICAgICAgIGJ1aWxkKDIgKiBuZCArIDIsIG0gKyAxLCByKTsKICAgICAgICBzdHJlZVtuZF0gPSBtZXJnZShzdHJlZVsyICogbmQgKyAxXSwgc3RyZWVbMiAqIG5kICsgMl0pOwogICAgfQp9CgpOb2RlIHFyeShpbnQgbmQsIGludCBsLCBpbnQgciwgaW50IHFsLCBpbnQgcXIpIHsKICAgIGlmIChsID09IHFsICYmIHIgPT0gcXIpIHsKICAgICAgICByZXR1cm4gc3RyZWVbbmRdOwogICAgfSBlbHNlIHsKICAgICAgICBpbnQgbSA9IChsICsgcikgLyAyOwogICAgICAgIGlmIChxciA8PSBtKSByZXR1cm4gcXJ5KDIgKiBuZCArIDEsIGwsIG0sIHFsLCBxcik7CiAgICAgICAgaWYgKHFsID4gbSkgcmV0dXJuIHFyeSgyICogbmQgKyAyLCBtICsgMSwgciwgcWwsIHFyKTsKICAgICAgICBOb2RlIHExID0gcXJ5KDIgKiBuZCArIDEsIGwsIG0sIHFsLCBtKTsKICAgICAgICBOb2RlIHEyID0gcXJ5KDIgKiBuZCArIDIsIG0gKyAxLCByLCBtICsgMSwgcXIpOwogICAgICAgIHJldHVybiBtZXJnZShxMSwgcTIpOwogICAgfQp9CgppbnQgbWFpbigpIHsKICAgIExvY2FsOyAvL2xvY2FsIHRlc3RpbmcKICAgIGludCBuLCBxOwogICAgY2luID4+IG4gPj4gcTsKICAgIGNpbiA+PiBTOwogICAgYnVpbGQoMCwgMCwgbiAtIDEpOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gcTsgKytpKSB7CiAgICAgICAgaW50IGEsIGI7CiAgICAgICAgc3RyaW5nIHFhbnM7CiAgICAgICAgY2luID4+IGEgPj4gYiA+PiBxYW5zOwogICAgICAgIGEtLTsKICAgICAgICBiLS07CiAgICAgICAgTm9kZSByID0gcXJ5KDAsIDAsIG4gLSAxLCBhLCBiKTsKICAgICAgICBzdHJpbmcgYW5zOwogICAgICAgIGlmIChyLnByZTdbMF0gPT0gNCAmJiByLnByZTZbMF0gPCA0KSBhbnMgPSAieWVzIjsKICAgICAgICBlbHNlIGFucyA9ICJubyI7CiAgICAgICAgc3RyaW5nIGNvcnIgPSBhbnMgPT0gcWFucyA/ICJjb3JyZWN0IiA6ICJpbmNvcnJlY3QiOwogICAgICAgIGNvdXQgPDwgYW5zIDw8ICIgIiA8PCBxYW5zIDw8ICIgIiA8PCBjb3JyIDw8ICdcbic7CiAgICB9CiAgICByZXR1cm4gMDsKfQo=