Recursion#553

Recursion

1 second
128 megabytes
Very easy

One of the important concepts used in the theory of algorithms is recursion. Informally, recursion can be defined as the use of the description of the object itself. If we are talking about a procedure, then in the process of execution, this procedure calls itself either directly or indirectly (through other procedures).

Recursion is a very "powerful" method of constructing algorithms, but it also contains certain dangers. For example, a carelessly written recursive procedure may enter into infinite recursion and never complete its execution (in practice, the execution will end with a stack overflow).

Because recursion can be indirect (a procedure can call itself through other procedures), determining whether a particular procedure is recursive can be quite challenging.

Consider a program consisting of procedures P_1, P_2, \dots, P_n. For each procedure, we know which procedures it can call. A procedure is said to be potentially recursive if there exists a sequence of procedures Q_0, Q_1, \dots, Q_k such that Q_0 = Q_k = P and for i = 1 \ldots k, the procedure Q_{i-1} can call Q_i.

You need to write a program that determines for each of the given procedures whether it is potentially recursive.

Input

The first line contains the number (1 \leq n \leq 100) of procedures in the program. Then follow blocks describing the procedures. The blocks are separated from each other by lines, each consisting of "*" (asterisk) characters.

The description of a procedure starts with a line containing its identifier, which consists only of lowercase Latin letters and digits. An identifier can begin with either a letter or a digit. The identifier's length is from to characters. Next is a line containing the number (k \leq n), the number of procedures that can be called by this procedure. The following lines contain the identifiers of these procedures, one per line.

Different procedures have different identifiers. No procedure may call a procedure that is not described in the input.

Output

For each procedure present in the input, in the order they are listed in the input, output a separate line with the name of the procedure, then a colon, a space, and then the word YES if the procedure is potentially recursive, or NO otherwise.

Examples

Example 1

Loading
Loading