#include <bits/stdc++.h>
#include "testlib.h"

using namespace std;

int const MAX_OPS = 20000;

int readAns(InStream& in, int n, vector<int> a, vector<int> b) {
	int ops = in.readInt(-1, MAX_OPS, "ops");
	if (ops == -1) {
		return -1;
	}
	for (int i = 0; i < ops; i++) {
		int pos = in.readInt(1, n - 1, format("s[%d]", i + 1));
		pos--;
		if (abs(a[pos] - a[pos + 1]) <= 1) {
			in.quitf(_wa, "Trying to swap elements %d and %d on 0-based indices %d and %d on step %d", a[pos], a[pos + 1], pos, pos +1, i);
		}
		swap(a[pos], a[pos + 1]);
	}
	if (a != b) {
		in.quitf(_wa, "a and b must be equal in the end");
	}
	return ops;
}

int main(int argc, char* argv[]) {
    registerTestlibCmd(argc, argv);
    int n = inf.readInt();
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
    	a[i] = inf.readInt();
    }
	for (int i = 0; i < n; i++) {
    	b[i] = inf.readInt();
    }
	int ansOps = readAns(ans, n, a, b);
	int partOps = readAns(ouf, n, a, b);
	if (ansOps == -1) {
		if (partOps == -1) {
			quitf(_ok, "OK, no solution");
		} else {
			quitf(_fail, "Jury didn't find a solution, but participant did, n = %d, ops = %d", n, partOps);
		}
	} else {
		if (partOps == -1) {
			quitf(_wa, "Jury has a solution, but participant didn't find any, n = %d", n);
		} else {
			quitf(_ok, "OK, found solution, n = %d, ops = %d", n, partOps);
		}
	}
}