#include "testlib.h"
#define MAXN 300

int units[MAXN], desks[MAXN];

int main(int argc, char *argv[])
{
	registerTestlibCmd(argc, argv);
	int pans = ouf.readInt(0, 1);
	int jans = ans.readInt();
	if (pans != jans)
	{
		if (jans) quitf(_wa, "Jury found the answer, but participant didn\'t");
		else quitf(_wa, "Participant found the answer, but jury didn\'t");
	}
	if (!jans)
		quitf(_ok, "OK");
	int m = inf.readInt();
	int n = inf.readInt();
	for (int i = 1; i <= m; i++)
		units[i] = inf.readInt();
	for (int i = 1; i <= n; i++)
		desks[i] = inf.readInt();
	for (int i = 1; i <= m; i++)
	{
		std::vector <int> a;
		std::set <int> s;
		do {
			int x = ouf.readInt(1, n);
			a.push_back(x); s.insert(x);
		} while (!ouf.seekEoln());
		if (a.size() != units[i])
			quitf(_wa, "Expect %d numbers in the %d-th line", units[i], i);
		if (a.size() != s.size())
			quitf(_wa, "Multi-people from the same unit in the same desk");
		for (int x : a)
			if (--desks[x] < 0)
				quitf(_wa, "too many people on desk %d", x);
	}

	quitf(_ok, "OK");
	return 0;
}
