Easy game?

Consider the following game. You start with an empty set of words SS. Afterwards, you will be given words one by one. For every given word ww, if ww is not in SS, insert ww in SS, and if ww is already in SS, remove ww from SS. At the end of the process, you must list

Input

Input consists of one or more cases. Every case consists of words made up of only lowercase letters. Each case ends with “END”, except the last case, which ends with “QUIT”.

Take into accout that the “big” private test cases have words repeated many times. If your program uses too much memory, you may receive a “WA” veredict.

Output

For every case, print its game number starting at 1. Then, print the words that are in SS, followed by a blank line, followed by the words that are not in SS but that at some moment were in SS. The first list must be sorted in alphabetical order. The second list must be sorted by the length of the words (first the shorter words), using alphabetical order to break ties. Separate the output of two consecutive games by a blank line.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T11:05:38.347Z

© Jutge.org, 2006–2026.
https://jutge.org