import ru.ifmo.testlib.InStream;
import ru.ifmo.testlib.Outcome;
import ru.ifmo.testlib.Outcome.Type;

import java.util.*;

public class Check implements ru.ifmo.testlib.Checker {
	@Override
	public Outcome test(InStream inf, InStream ouf, InStream ans) {
		int n = inf.nextInt();
		ArrayList<String> mas = new ArrayList<String>();
		for (int i = 0; i < n; i++)
			mas.add(inf.nextToken());
		
        ArrayList<Integer> p = readData(ouf, Type.WA, n);
		ArrayList<Integer> j = readData(ans, Type.FAIL, n);
		
        StringBuffer pAns = build(mas, p);
		StringBuffer jAns = build(mas, j);
		
        if (jAns.toString().compareTo(pAns.toString()) < 0)
			return new Outcome(Type.WA, "Jury has better answer!");
		if (jAns.toString().compareTo(pAns.toString()) > 0)
			return new Outcome(Type.FAIL, "Participant has found better solution :(");
		return new Outcome(Type.OK, "Ok!");
	}

	public ArrayList<Integer> readData(InStream a, Type b, int n) {
		ArrayList<Integer> per = new ArrayList<Integer>();
		for (int i = 0; i < n; i++)
			per.add(a.nextInt() - 1);
		boolean used[] = new boolean[n];
		for (int i = 0; i < n; i++) {
			if (per.get(i) < 0 || per.get(i) > n)
				throw new Outcome(b, "Incorrect index: " + (i + 1));
			if (used[per.get(i)])
				throw new Outcome(b, "Usage of string #" + (per.get(i) + 1)
						+ " 2 or more times");
			used[per.get(i)] = true;
		}
		for (int i = 0; i < n; i++)
			if (!used[i])
				throw new Outcome(b, "No usage of the string #" + (i + 1));
		return per;
	}

	public StringBuffer build(ArrayList<String> mas, ArrayList<Integer> id) {
		StringBuffer olo = new StringBuffer("");
		for (int i = 0; i < mas.size(); i++)
			olo.append(mas.get(id.get(i)));
		return olo;
	}

}
