#ifdef THEMIS
#include "testlib_themis.h"
const std::string TASK_NAME = "COMPATNUM";
#define _100 1.0
#else
#include "testlib.h"
#define _100 100.0
#endif // THEMIS

#include <bits/stdc++.h>
using namespace std;

int n;
vector<int> a;

void readInput() {
    n = inf.readInt();
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        a[i] = inf.readInt();
    }
}

void readOutput() {
    vector<int> answer(n);
    for (int i = 0; i < n; ++i) {
        answer[i] = ans.readInt();
    }
    vector<int> contestant(n);
    for (int i = 0; i < n; ++i) {
        contestant[i] = ouf.readInt();
    }

    set<int> aset(a.begin(), a.end());
    for (int i = 0; i < n; ++i) {
        int ai = a[i];
        int out = contestant[i];
        int ref = answer[i];
        if (out == -1) {
            if (ref != -1) {
                quitf(_wa, "Dòng %d: Có tồn tại số a_j thỏa mãn a[%d] & a_j == 0, nhưng bạn lại in -1!", i+1, i+1);
            }
        } else {
            // out phải thuộc a và ai & out == 0
            if (aset.find(out) == aset.end()) {
                quitf(_wa, "Dòng %d: Số %d không thuộc mảng đầu vào!", i+1, out);
            }
            if ( (ai & out) != 0 ) {
                quitf(_wa, "Dòng %d: a[%d]=%d & %d != 0!", i+1, i+1, ai, out);
            }
        }
    }
    quitf(_ok, "Kết quả hợp lệ!");
}

int main(int argc, char *argv[]) {
#ifdef THEMIS
    registerTestlibThemis(TASK_NAME + ".inp", TASK_NAME + ".out");
#else
    registerTestlibCmd(argc, argv);
#endif
    readInput();
    readOutput();
    return 0;
}
