compiler-6

Kamal is an amazing coder. He normally gets over excited during compilers lab, as compilers is his favorite subject.

One fine day, the professor taught everyone about lex and yacc, and gave a sample lexical analyzer creation as the class work. As we all know, Kamal wants to be the first one to show the output. So he codes blazingly fast, and gets the lex and yacc file. He then gave certain inputs and obtained some values as outputs. Now, Kamal, as his mind is preoccupied with thinking about important things, did not want to test the outputs that he got for validity. So, he asks you to do so. Given the inputs and the outputs, check if it is correct or not.

After printing the required answer, print the line, "Code completed, sir!", which is precisely what Kamal would say while raising his hand.

The work:
    The input would be a statement following the given set of rules. The statement represents a sample code which does two operation:
        1) loop() : loop the blocks following it, n number of times
        2) ASSIGN :  Do an assignment operation.

    Rules:
        `
        line> --> <line><line> | <loop> | <assignment> | ""
        <loop> --> loop(<value>) { <line> }
        <assignment> --> ASSIGN;
        <iter> --> <n>
        `

Input:
    The first line contains the integer ite, the number of queries
    The next line contains the string s, for which the answer is to be found.

Output:
    Print the required answer, one per line

Constraints:
    ite ≤ 100
    |s| ≤ 2500
    n ≤     2^63 -1
    It is guarenteed that the answers will not exceed 2^63 -1

SAMPLE INPUT
2
ASSIGN;loop(10){ASSIGN;}
loop(100){loop(100){}}

SAMPLE OUTPUT
11
0
Code completed, sir!

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions: