Definite Values

No attempts yetTime limit1sMemory limit128 MB

Problem

A common mistake in programming is to use variables that have not been initialized. For example, in C and C++ every variable holds an indefinite value right after it is declared — it can be anything. Thus the following program

main()
{
    int x;
    printf("%d\n", x);
}

could print any number. But even in languages such as Pascal, where every value is initialized to zero, it is good practice to give variables definite values before using them, so as to avoid side effects when your code fragment is placed in a different context.

In general, deciding for a given program whether every variable has been assigned a value before it is read is undecidable. But if, as in this problem, you consider only a sequence of assignments, the problem becomes solvable.

Input

The input contains several program parts. Each part starts with an integer $n$ on a line by itself — the number of lines in that part. The following $n$ lines each contain an assignment of the form "variable1 = variable2", where each variable is a single lower-case letter.

The input is terminated by a part with $n = 0$.

Output

Assume that before a program part is executed, variable a has a definite value while every other variable is undefined. An assignment "variable1 = variable2" makes variable1 definite only if variable2 currently has a definite value; otherwise variable1 becomes undefined. After executing each program part, print the names of the variables that have a definite value.

For each program part, first print the line "Program #k", where k is the program number starting from 1. On the next line print the names of the variables that have a definite value, sorted alphabetically, with one blank after each name. If no variable has a definite value, print "none".

Separate the outputs of consecutive program parts with a single blank line.