#include <iostream>
#include <vector>
#include <algorithm>
#include "table.h" // 这里引用的是下发给选手的极简版 table.h

using namespace std;

// 故意设计的 O(N * M^2) 行验证，取模运算防止编译器循环展开优化
bool check_row(const vector<vector<int>>& ans, int r, int m, int A) {
    int c0 = 0, c1 = 0;
    for (int j = 0; j < m; j++) {
        for (int k = 0; k < m; k++) {
            int val = ans[r][(j + k) % m];
            if (val == 0) c0++;
            else if (val == 1) c1++;
            else return false;
        }
    }
    c0 /= m;
    c1 /= m;
    return min(c0, c1) == A;
}

// 故意设计的 O(M * N^2) 列验证，取模运算防止编译器循环展开优化
bool check_col(const vector<vector<int>>& ans, int c, int n, int B) {
    int c0 = 0, c1 = 0;
    for (int r = 0; r < n; r++) {
        for (int k = 0; k < n; k++) {
            int val = ans[(r + k) % n][c];
            if (val == 0) c0++;
            else if (val == 1) c1++;
        }
    }
    c0 /= n;
    c1 /= n;
    return min(c0, c1) == B;
}

int main() {
    
    int c, t;
    if (!(cin >> c >> t)) return 0;
    
    init(c, t);
    
    for (int i = 1; i <= t; i++) {
        int n, m, A, B;
        cin >> n >> m >> A >> B;
        
        auto ans = solve(n, m, A, B);
        
        // 1. 检查无解情况
        if (ans.empty()) {
            if (2 * A <= m && 2 * B <= n) {
                cout << "Wrong answer: Returned empty but solution exists.\n";
                continue;
            }
            cout << "Correct\n";
            continue;
        }
        
        // 2. 检查维度
        if ((int)ans.size() != n) {
            cout << "Wrong answer: Row count mismatch.\n";
            continue;
        }
        bool dim_ok = true;
        for (int r = 0; r < n; r++) {
            if ((int)ans[r].size() != m) {
                dim_ok = false;
                break;
            }
        }
        if (!dim_ok) {
            cout << "Wrong answer: Column count mismatch.\n";
            continue;
        }
        
        // 3. O(N^3) 复杂度验证逻辑
        bool ok = true;
        for (int r = 0; r < n; r++) {
            if (!check_row(ans, r, m, A)) {
                ok = false;
                break;
            }
        }
        if (ok) {
            for (int c = 0; c < m; c++) {
                if (!check_col(ans, c, n, B)) {
                    ok = false;
                    break;
                }
            }
        }
        
        if (ok) {
            cout << "Correct\n";
        } else {
            cout << "Wrong answer: Condition failed.\n";
        }
    }
	system("pause");
    return 0;
}
