The BASIC computer programming language has been popular for many years, and there have been dozens of ‘dialects’ of the language. It’s considered a high-level language and is typically interpreted (rather than compiled). For this problem, write an interpreter for a restricted dialect of BASIC. Here is a description of the language.

Each input line contains one statement. Each statement begins with a non-negative integer, which we will call its label. Following the label is a single space and one of the following commands (with explanations following):
 - LET X = <ARITHMETIC_STATEMENT>

 Assign the result of the arithmetic statement to variable X.
 - IF <CONDITION> THEN GOTO L

 If the boolean given is true, then go to the statement labeled L, where L is a valid label. (If the condition is not true, continue execution to the statement with the next lowest label.)
 - PRINT <PRINT_STATEMENT>

 Produce output, without an appended newline.
 - PRINTLN <PRINT_STATEMENT>

 Produce output, with an appended newline.

Here are details on types, variables, and the terms <ARITHMETIC_STATEMENT>, <CONDITION>, and <PRINT_STATEMENT> used above.
 - All numeric values (in the input and for the variable representation) are signed 32-bit integers.
 - All variables are single uppercase characters (A through Z). They are all global in scope, and are all initialized to zero before program execution begins.
 - <ARITHMETIC_STATEMENT> is one of the following: X, X + Y, X - Y, X * Y, or X / Y. Here, X and Y each indicate either a variable or an integer.
 - <CONDITION> is one of the following: X = Y, X > Y, X < Y, X <> Y, X <= Y, or X >= Y. Again, X and Y each indicate either a variable or an integer. Here, <> indicates inequality.
 - <PRINT_STATEMENT> is either a variable name or a literal string delimited by double quotes. Inside the quotes, the string contains only alphanumeric characters (a-z, A-Z, 0-9) and spaces.

In the signed 32-bit arithmetic, the usual rules of truncation towards zero (for division) and overflow (for addition and multiplication) and underflow (for subtraction) apply. The following examples illustrate these conditions:

5 / 2   = 2  65536 * 32768   = -2147483648
-1 / 2  = 0  -65536 * 32768  = -2147483648
2147483647 + 1  = -2147483648        -2147483648 * 2 = 0
-2147483648 - 1 = 2147483647 2147483647 * 2  = -2

Further, division by zero will not occur.

Program execution begins with the statement having the smallest label, and proceeds with the statement having the next smallest label. (Unless a GOTO executes, in which case execution proceeds at the designated label.) The program halts after it has completed the statement with the largest label (which is guaranteed not to contain a GOTO).

-----Input-----
Input consists of a single program. Each line contains a single valid statement. Each pair of adjacent tokens in the input is separated by a single space. Integers in the input will all be in the range $-2^{31}$ to $2^{31}-1$. Input ends at end of file.

-----Output-----
Give the output (PRINT and PRINTLN statements) of the input program when it is executed.

-----Examples-----
Sample Input:
10 LET A = 1
20 PRINT "HELLO THERE "
30 PRINTLN A
40 LET A = A + 1
50 IF A <= 5 THEN GOTO 20
60 PRINTLN "DONE"
Sample Output:
HELLO THERE 1
HELLO THERE 2
HELLO THERE 3
HELLO THERE 4
HELLO THERE 5
DONE

Source: kattis | Difficulty: HARD


Solutions: