Many people fondly remember early home computers and their built-in BASIC programming language. There has been a surge of nostalgic development as teams compete to recreate these iconic systems. You have been asked to help team "Gooseberry Tart" by building them a BASIC interpreter called GTB1. Because modern machines have plenty of memory and are expected to process video streams in real time, your interpreter must run fast. Your task is to implement an interpreter for the limited subset of the language specified below.
<expression> is integer-valued. Boolean comparison syntax appears only inside the IF statement.A–Z, a–z) and may continue with letters or digits. A name can be any length, but only the first two characters matter, and names are case-insensitive. For example Fred, Fr, Freda, and fRE all refer to the same variable.LET, GOTO, IF, FOR, TO, NEXT, OUT, and COMMENT.( ) and the binary operators + - * / % (addition, subtraction, multiplication, integer division, and modulo) with the usual precedence.+ and -.GOTO, an IF, a FOR, a NEXT, an OUT, or a comment.Statement forms
LET <variable> = <expression>GOTO <line number>IF <expression> <comparison> <expression> GOTO <line number>, where <comparison> is one of =, <, >, <=, >=, or <> (equal, less than, greater than, less than or equal, greater than or equal, not equal).FOR <variable> = <start expression> TO <end expression>NEXT <variable>COMMENT <any text>OUT <expression>FOR / NEXT loops
A loop is a matching FOR and NEXT pair that use the same variable. It begins with the FOR statement, contains the loop body, and ends with the NEXT statement. When the FOR statement runs, the start expression is assigned to the variable and the body executes at least once. Each time the NEXT statement runs it adds $1$ to the variable; if the result is less than or equal to the end expression, the body executes again. The end expression is re-evaluated on every NEXT. Loops may be nested, and the nesting must be proper (an inner FOR/NEXT lies entirely between its outer FOR and NEXT). A GOTO may jump into or out of a FOR/NEXT structure.
Execution
Statements normally execute in the numerical order in which they are written, starting at the first line. GOTO and IF can change this order. A program finishes when execution runs off the end. Variables need not be declared: they come into existence when first assigned or referenced, and a variable referenced before it is assigned has the value $0$. The OUT statement prints one line containing the value of its expression.
The input is a sequence of programs. Each program starts with a line containing an integer $N$, the number of lines in the program, with $1 \le N \le 1000$. It is followed by $N$ statement lines. No statement is longer than $80$ characters. Tokens may be separated by more than one space, and a line may have leading or trailing spaces; there are no tabs, and operators and parentheses need not be surrounded by spaces. Each statement line has a line number and a statement. The input ends with a program whose $N$ is $0$. Every program is syntactically correct and is guaranteed to terminate.
For each program, print a line Programme <i> (where <i> is $1, 2, 3, \dots$), followed by every line produced by the program's OUT statements, in order.
The original test data may require executing up to $10^9$ instructions, so an efficient interpreter is expected.