#include "testlib.h"
#include <string>
#include <vector>
#include <sstream>
#include <cmath>

using namespace std;

typedef vector<int> vi;


int main(int argc, char * argv[])
{	
    setName("checker for problem 'student'");
    registerTestlibCmd(argc, argv);

	int N = inf.readInt();
	vi K(N);
	int T = 0;
	for (int i = 0; i < N; ++i) {
		K[i] = inf.readInt();
		T += K[i];
	}
	
	vi part_to_job(T);
	vi part_to_jobpart(T);
	int part = 0;
	vector<vi> p(N), w(N);
	for (int i = 0; i < N; ++i) {
		p[i].resize(K[i]);
		for (int j = 0; j < K[i]; ++j) {
			p[i][j] = inf.readInt();
			part_to_job[part] = i;
			part_to_jobpart[part] = j;
			++part;
		}
	}
	
	for (int i = 0; i < N; ++i) {
		w[i].resize(K[i]);
		for (int j = 0; j < K[i]; ++j)
			w[i][j] = inf.readInt();
	}

	long long cost = ouf.readLong();
	long long cans = ans.readLong();
	
	if (cost > cans)
		quitf(_wa, "wa");
		
	long long cur_time = 0;
	vi used(T);
	int cur_job = -1;
	int count = 0;
	long long cur_cost = 0;
	
	for (int i = 0; i < T; ++i) {
		int part = ouf.readInt(1, T);
		--part;
		if (used[part])
			quitf(_wa, "wa");
		used[part] = 1;

		int job = part_to_job[part];
		if (job != cur_job && cur_job != -1)
			quitf(_wa, "wa");
		cur_job = job;
		count++;
		if (count == K[job]) {
			count = 0;
			cur_job = -1;
		}
		
		cur_time += p[job][part_to_jobpart[part]];
		cur_cost += cur_time * w[job][part_to_jobpart[part]];
	}
	
	if (cur_cost != cost)
		quitf(_wa, "wrong cost");
		
	if (cost < cans)
		quitf(_fail, "user has found better solution");
	
    quitf(_ok, "ok");
}
