Processor`s game
Vasya Pupkin’ coursework on electronics is to create a simple microprocessor. According to the statement this microprocessor has only three registers: the accumulator, the instruction pointer and stack pointer. The accumulator has 60 bits, the instruction and stack pointers has 7 bits. The accumulator can store positive and negative numbers (in binary complement code: Binary complement code of negative number is equal to difference between 260 and absolute value of that negative number. For example, -5 in decimal complement code could be written as 1152921504606846971, and in binary com-plement code as 111111111111111111111111111111111111111111111111111111111011).
The processor can execute the following commands (ACC – the accumulator, IP – instruction pointer, SP – stack pointer, [X] – element of the stack with the address X):
The program is located in cells with addresses from 0 to 127. Each memory cell can contain exactly one command (including the constant value, if it exists). Be-fore beginning execution, the accumulator is set to the value to be processed, and reg-isters IP and SP are zeroed. The result of calculation is the value of the accumulator after the program stops.
Given microprocessor program, write a program that calculates its result for each provided accumulator value.
Input
The first line contains two integers n and m, separated by spaces, where n – number of commands in the program, m – number of values of accumulator for which you should make calculations. The subsequent n lines contain the commands in the following format:
"Address of memory cells," "space" "command’s mnemonic" ["space", "argument."]
Command are listed sequentially from cell with address 0 to cell with address n-1.
The program is followed by m integers a_i – initial values of the accumulator, which should be processed by microprocessor. The numbers are separated by spaces.
1 ≤ n ≤ 128; 1 ≤ m ≤ 10^3, –2^59 ≤ a_i < 2^59.
All mnemonics are written with capital Latin letters, and a constant X is specified as a decimal number (possibly signed) ranged from –2^59 ≤ X < 2^59; for the CALL command 0 ≤ X ≤ 127.
The given program has a finite run time, and never overflows the stack.
Output
The first line of the output file should contain integer m – the number of calculated values. Following m lines should contain the results of calculations for input values a_i, placed in the same order as a_i,, one per line.