This page is still under construction.

Parts of this page are still being built. What you see may change.

Beam me out!

Time limit1sMemory limit256 MB

Summary
Decide whether a random walk from room 1 reaches room n with certainty and whether every possible walk ends within a bounded number of steps.
Level

Medium7 of 10

Topics
Graph, DFS, Topological sort
Solved
No attempts yet

Problem

King Remark is a lenient ruler. A wrongdoer who repents his crimes gets a second chance in the Great Maze.

Today's delinquent is a well known computer scientist. His fame did him no good after he declined to study the randomized algorithms that king Remark invented. Those algorithms may run for a very long time, may never stop at all, and are not guaranteed to give a right answer even when they do stop.

The Great Maze was rebuilt with the newest beaming technology, which made all doors unnecessary. Once the delinquent says the magic words "I was wrong and will never disappoint king Remark again!", he is beamed to the next room at once. That room is chosen at random from the list of goal rooms written in the room he is standing in.

The Great Maze has nn rooms numbered 11 to nn. Every detainee starts in room 11 and receives his pardon once he reaches the throne room nn. If he ends up in a room whose list of goal rooms is empty, his tour is over there. Saying the magic words again in that room does not hurt him, but it does not help him either.

King Remark dislikes surprises and asks two questions. Is the delinquent guaranteed to reach the throne room, and is there a limit on the number of beaming operations after which the game is over for sure?

Every room on a list is chosen with probability greater than 00.

Input

The input contains a single test case.

The first line contains the number of rooms in the Great Maze, nn (2≤n≤500002 \le n \le 50000).

Two lines follow for each of the rooms 11 to n−1n-1, in that order. Reaching the throne room nn ends the quest, so the list of room nn is not part of the input.

The first of the two lines contains the number of goal rooms on the list, mm (0≤m≤n0 \le m \le n). The second line contains the mm goal rooms, and it is an empty line if m=0m = 0. Every list consists of integers between 11 and nn, inclusive, and is sorted in strictly increasing order, so no room appears twice on the same list.

The total number of goal rooms summed over all lists does not exceed 10610^6.

Output

Print two words on one line, separated by a space.

  • The first word is PARDON if the probability that the delinquent reaches the throne room during his random walk is 100%, and PRISON otherwise.
  • The second word is LIMITED if a limit on the number of beaming operations exists, and UNLIMITED otherwise.

Examples4

  1. Example 1

    Input
    3
    2
    2 3
    1
    3
    
    Expected output
    PARDON LIMITED
    
  2. Example 2

    Input
    3
    2
    2 3
    0
    
    Expected output
    PRISON LIMITED
    
  3. Example 3

    Input
    3
    2
    2 3
    2
    1 3
    
    Expected output
    PARDON UNLIMITED
    
  4. Example 4

    Input
    3
    2
    2 3
    1
    2
    
    Expected output
    PRISON UNLIMITED