ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1129. Door Painting

Time limit: 0.25 second
Memory limit: 64 MB
There are many rooms, corridors and doors between them in the kindergarten. Some repairs are planned to be made soon. The doors are agreed to be painted in bright cheerful colors: green and yellow. The matron of the kindergarten wants the doors to satisfy the following condition: the sides of an arbitrary door must have the different colors. The number of green doors in each of the lodgings must differ from the number of yellow doors not more than by one. Given the plan of the kindergarten suggest your scheme of door painting.

Input

The first line contains the number of lodgings N ≤ 100 in the kindergarten. The next N lines contain description of the door configuration (k+1-st line contains a description of the k-th lodging). Each of the N lines starts with the number of doors that connect this lodging with adjacent ones. Then there are numbers of adjacent lodgings separated with a space (these numbers follow in ascending order).

Output

should contain a required painting scheme or the word “Impossible” if it is impossible to satisfy the requirements. The colors of the K-th room doors should be put in the K-th line in the same order as they were in the input data. The green color is denoted by G, yellow — by Y.

Sample

inputoutput
5
3 2 3 4
3 1 3 5
4 1 2 4 5
3 1 3 5
3 2 3 4
G Y G
Y G Y
G Y Y G
Y G G
G Y Y
Problem Author: Magaz Asanov
Problem Source: VI Ural State University Collegiate Programming Contest (21.10.2001)