Passing Game#10234

Passing Game

1 second
64 megabytes
Very easy

A group of people is participating in a passing game. In this game, some participants have received a special message. Anyone who spends at least minutes near someone with the message is considered to have received the message indirectly and is told to spread it further.

Those who do not receive the message directly, but spend at least minutes near those who did, are advised to pay close attention in the next round of the game.

Your task is to determine the list of individuals who have received the message indirectly and those who need to pay close attention.

Input

The first line provides the total number of individuals (3 \leq N \leq 1000).

The second line specifies the number – the number of initial message holders, followed by their list C_i (1 \leq i \leq M).

The third line indicates the number – the number of contact records.

The next lines each describe a contact record with three integers: two individual numbers and the number of minutes they were in contact.

Output

On the first line, list in ascending order the numbers of individuals who received the message indirectly. On the second line, list in ascending order the numbers of individuals who need to pay close attention in the next round.

Examples

Example 1

Loading
Loading

Note

Z10.png

Based on the input data, individual initially received the message.

Since individual spent at least minutes ( minutes) with individual , individual is considered to have received the message indirectly and should help spread it.

Individuals and spent at least minutes ( and minutes respectively) with individual , so they need to pay close attention in the next round.