Recursion#1391

Recursion

1 second
64 megabytes
Very hard

Recursion. n. masc. see recursion.

Folklore

Petro is developing a new development environment for the language Ж±. He is currently working on a module to detect potential infinite recursion.

Ж± is a procedural language in which all variables are binary, meaning each variable can have either the value "" or "". Each procedure in Ж± can take several arguments. The language supports the following operators:

A procedure is defined as: "<procedure name> (<argument list>) S" where S is an arbitrary operator.

All arguments are passed by value (that is, changes within the procedure do not modify the values of the corresponding variables in the calling procedure).

For example, the program in the first example contains a procedure "inc" which takes a three-bit value via three arguments x2, x1, and x0, and eventually calls the procedure "done" with three arguments representing the value incremented by one.

Given the program, determine whether it is possible to call some procedure with arguments such that the result is infinite recursion.

Input

The input file contains a program written in the language Ж±. It contains at most procedures, each with at most arguments. The input file size does not exceed bytes. Procedure and argument names consist of letters and digits and are case-sensitive. All names are no longer than characters. No procedure is named "if" or "else".

Output

Output "YES" if it is possible to call some procedure with arguments resulting in infinite recursion, otherwise output "NO".

Examples

Example 1

Loading
Loading