cho.sh
Notes
Loading...

Messages

Time limit

1s

Memory limit

128 MB

Problem

Misfits Academy runs an activity to help troublesome children practice being considerate toward one another.

The children sit in a circle, and each child writes their own name at the top of a sheet of paper. Then everyone passes their paper to the child on the left. When a child receives a sheet, they write a kind message for the child whose name is at the top. After writing the message, they fold that part of the paper to hide it and pass the sheet to the left again. The activity ends when each child receives the sheet with their own name on top, and everyone reads the messages left for them.

However, some children write hurtful messages instead of compliments. Given the marks on each sheet, determine who wrote a hurtful message about whom.

Input

The input consists of several groups. Group numbers start at 1 and increase by 1 in input order.

Each group begins with an integer n, the number of participating children. It satisfies 5 <= n <= 20. The next n lines describe the completed sheets in the same order as the children sat and passed papers. The child on the first line passed a paper to the child on the second line, and the child on the last line passed a paper to the child on the first line.

Each line starts with the name at the top of the sheet, followed by n-1 message marks as they appear from top to bottom on that sheet. A kind message is marked P, and a hurtful message is marked N. Because the folded sheet is read from top to bottom, the first mark after a name was written by the child on the immediately previous input line for that group, the second mark by the child two lines before, and so on, wrapping around the circle.

Each name contains only uppercase or lowercase English letters and has length at most 60. A final line containing 0 ends the input and is not processed.

Output

For each group, first print the group number in the form Group 1. Then print one line for each hurtful message in the form A was nasty about B, where A is the writer and B is the child named on the sheet.

If there are multiple hurtful messages, print them in input order: first by sheet order, then from left to right within the marks on that sheet. If there are no hurtful messages, print Nobody was nasty.

Print one blank line after each group's output.