Segments on the Line Return-2#1700

Segments on the Line Return-2

2 seconds
64 megabytes
Very hard

When developing a program to verify a participant's solution to the previous problem "Segments on a Line Return" (please refer to its description!), the jury faced challenges that were more complex than the problem itself. With the thought "why not?", it was decided to include the creation of such a verification program in the task set as well.

The verification program has access to three sets of information:

Your task is to write a program that uses these data to determine whether the abstract participant's solution is correct.

Input

The input consists of three parts. The first part begins with the number (1 \leq N \leq 100000), followed by pairs a_i, b_i (-10^9 \leq a_i < b_i \leq 10^9). Next, there are numbers, each ranging from to , where the -th number indicates the segment that directly contains the -th segment, or zero, according to the abstract participant. Finally, there are another numbers in the same format, representing the jury's answer to the problem.

The input data is always correct. This means, for instance, that the participant's answer does not need to be checked for format compliance, and the jury's answer is guaranteed to be correct.

Output

Print lines. On the -th line, output OK if the abstract participant's answer for the -th segment is correct, and WA if it is not.

Examples

Example 1

Loading
Loading