QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#9029. Skittles

Statistics

AK Tang and Feifei are good friends, and their classmates are deeply envious of their relationship. One day, both of them received a letter containing several integers from $1$ to $m$ and a rainbow candy. AK Tang and Feifei realized that this was an invitation to a game.

AK Tang's letter contains $tot_a$ numbers, where the $i$-th number is $a_i$. Feifei's letter contains $tot_b$ numbers, where the $i$-th number is $b_i$. They were surprised to find that the numbers satisfy the following conditions:

  • All elements in $a$ are distinct.
  • All elements in $b$ are distinct.
  • For any $x \in [1, m]$, the number of $i \in [1, tot_a]$ such that $a_i = x$ plus the number of $j \in [1, tot_b]$ such that $b_j = x$ is at most $1$.

They then arrived at a plaza filled with piles of rainbow candies. Initially, there are $n$ piles of rainbow candies on the plaza, and the number of candies in each pile is already known to both AK Tang and Feifei.

The players take turns. In each turn, a player chooses a pile of rainbow candies that satisfies certain conditions and splits it into two non-empty piles of rainbow candies. During this process, the total number of rainbow candies does not decrease. That is, if you split a pile of $x$ candies into two piles of $y$ and $x-y$ candies ($0 < y < x$).

For a player, a pile of $x$ candies can be chosen if and only if $x$ appears in their own letter. That is, if a player chooses a pile of $x$ candies to perform the operation, the move is valid if and only if:

  • AK Tang is performing the move, and $x$ appears in sequence $a$.
  • Feifei is performing the move, and $x$ appears in sequence $b$.

When a player cannot make any move, they lose, and the game ends. The prize for each game is a limited-edition giant rainbow candy. Both AK Tang and Feifei love rainbow candies very much, so they will both use the optimal strategy.

Feifei thinks that eating too many rainbow candies in one day is not good, especially the limited-edition giant ones. He decides to ask you to predict the result of each game before it starts, so that he can give the extra rainbow candies to you!

Input

The first line contains two integers $n$ and $m$, as described above.

The second line contains one integer $tot_a$, representing the number of integers in AK Tang's letter.

The third line contains $tot_a$ integers, where the $i$-th integer is $a_i$.

The fourth line contains one integer $tot_b$, representing the number of integers in Feifei's letter.

The fifth line contains $tot_b$ integers, where the $i$-th integer is $b_i$.

The sixth line contains $n$ integers, where the $i$-th integer $P_i$ is the initial number of candies in the $i$-th pile.

It is guaranteed that $1 \le a_i, b_i \le m$, and all elements in $a$ and $b$ are distinct.

Output

Output one line representing the result of the game.

If AK Tang wins, output "Pomegranate", otherwise output "Orange". (Neither includes the quotation marks.)

Examples

Input 1

2 3
1
1
1
2
1 3

Output 1

Orange

Input 2

3 5
2
5 4
3
1 3 2
5 1 1

Output 2

Pomegranate

Input 3

5 7
3
5 3 7
2
2 6
6 4 6 6 2

Output 3

Orange

Subtasks

This problem uses subtask testing. Your program will only receive the score for a subtask if it passes all test cases within that subtask.

For all data, $0 < P_i \le 10^9$, $n \le 10^6$, $tot_a, tot_b \le m \le 10^4$.

Subtask ID Score $n \le$ $m \le$ $\sum P_i \le$ $\max P_i \le$ Special Constraints
1 11 8 $10^3$ 8 8 /
2 5 $10^6$ $10^3$ / $10^9$ $tot_a = 0$
3 5 $10^6$ $10^3$ / $10^9$ $tot_b = 0$
4 8 $10^3$ $10^2$ / $10^9$ /
5 23 $10^3$ $10^2$ / $10^9$ Every number in $[1, m]$ appears in the letters
6 21 $10^5$ $10^4$ / $m$ /
7 27 $10^6$ $10^4$ / $10^9$ /

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.