Processor's Game#2559

Processor's Game

1 second
64 megabytes
Very hard

Vasya Pupkin's coursework in electronics is to create a simple microprocessor. According to the assignment, this microprocessor has only three registers: the accumulator, the instruction pointer, and the stack pointer. The accumulator has bits; the instruction pointer and stack pointer have bits each. The accumulator can store both positive and negative numbers (in two's complement: the two's complement of a negative number is equal to the difference between 2^{60} and the absolute value of that negative number. For example, in decimal two's complement can be written as , and in binary two's complement as ).

The processor can execute the following commands ( — accumulator, — instruction pointer, — stack pointer, — element of the stack at address ):

The program is located in memory cells with addresses from to . Each memory cell can contain exactly one command (including the constant value, if any). Before execution begins, the accumulator is set to the value that needs to be processed, and the and registers are set to zero. The result of the computation is the value of the accumulator after the program stops.

Given a microprocessor program, write a program that computes the result for each provided accumulator value.

Input

The first line contains two integers and separated by a space: is the number of commands in the program; is the number of accumulator values for which the result should be computed. The next lines contain commands in the following format:

"Memory cell address," "space," "command mnemonic" ["space," "argument."]

Commands are listed sequentially from the cell with address to the cell with address n-1.

After the program, integers a_i follow — the initial values of the accumulator that must be processed by the microprocessor. The numbers are space-separated.

1 \le n \le 128. 1 \le m \le 10^3. -2^{59} \le a_i < 2^{59}.

All mnemonics are written in uppercase Latin letters, and the constant is specified as a decimal number (possibly with a sign) in the range -2^{59} \le X < 2^{59}. For the command, 0 \le X \le 127.

The given program has a finite execution time and never overflows the stack.

Output

The first line of the output should contain the integer — the number of computed values. The next lines should contain the computation results for input values a_i, in the same order as a_i, one per line.

Examples

Example 1

Loading
Loading