401466: GYM100460 L Icy Rider
Description
Where it's always a severe frost and howling blizzards, world-weary Icy Rider lives. Icy Rider will never die, will never melt, cannot move and cannot do anything at all. All what is left for him are his memories.
Before his way was ended, the Rider was forced to live through n events, in which m people took part. Each person is characterized by the relation of the Rider to this person — the integer from 1 to 109. The relation of the Rider to the event is the maximum of relations of the Rider to the people who took part in this event. It's known how the Rider relates to each of n events and also who exactly took part in which event. It's required to find out how the Rider relates to each of the m people.
InputThe first line contains two integers separated by the space: n and m (1 ≤ n, m ≤ 105) — the number of events memorable for Ice Rider and the number of people took part in these events. It is guaranteed that nm ≤ 106.
The next 2n lines contain the description of the events. In the -th line there are two integers separated by the space: ki and ci (1 ≤ ki ≤ m, 1 ≤ ci ≤ 109) — the total number of people took part in the i-th event and the relation of the Rider to this event. In the -th line there are ki integers separated by the spaces: pij (1 ≤ pij ≤ m) — the numbers of people who took part in the i-th event. For each certain event all the pij are distinct.
OutputIn the first line output «Good memory» (without quotes) if there exists at least one answer. In this case in the second line output m integers from 1 to 109 separated by the spaces — the relation of the Rider to the corresponding people. If there are multiple answers, output any of them. In the case the Rider got it wrong and no answer exists, in the only line output «Poor memory» (without quotes).
ExamplesInput3 3Output
1 1000
1
2 2000
1 2
3 3000
1 2 3
Good memoryInput
1000 2000 3000
3 3Output
1 3000
1
2 2000
1 2
3 1000
1 2 3
Poor memory