10497 - mid1 practice - queue   

Description

Consider a queue of groups. Each group has a unique ID denoted by a string of six uppercase alphabets, e.g. "IPHONE" or "GOOGLE". A new comer with a certain ID first checks if there exists a group of the same ID. If yes, then the new comer joins that group; otherwise, the new comer forms a new group at the end of the queue.

Input

The input is a sequence of IDs. Each ID is a string of six uppercase alphabets, except the last one, which is "END", indicating the end of the input.

Output

The output contains two lines. The first line shows the ID of the last group in the queue. The second line shows the size of the last group.

Note that each line of the output should be ended with a newline character '\n'.

Sample Input  Download

Sample Output  Download

Tags




Discuss