#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;
}
