Another “easy” problem

Professor Oak is desperate, searching for easy problems. Unfortunately, he is asking for the help of some students whose understanding of the word “easy” is questionable. It may be the case with this problem...

You are given some basic operations, and you just have to compute the result. To make the problem “less trivial”, you must compute the result for several initial values.

Input

Input consists of several cases. Each case starts with the number of operations nn and the number of initial values mm. Follow nn pairs of the kind + xx, * xx, / xx, xx, xx and xx, where the last three are the usual or, and and xor bitwise operations. Follow the mm initial numbers, all different, to which the operations must be applied.

Assume that nn and mm are between 1 and 10510^5, and that all the given numbers are between 0 and 101510^{15}. For every case, there are at most 100 operations that are not bitwise (that is, that are +, *, or /). With the given cases, all the intermediate and final results will be between 0 and 101510^{15}. You will never be asked to divide by 0.

Output

For every case, and for every initial number, print the result of applying all the operations in order. Print a line with 10 dashes at the end of every case.

For instance, consider the first initial number (1) of the first case. The result (10) is produced by these steps: 1+10=111 + 10 = 11, $11 \symbol{38} 3 = 3$, $3 \symbol{94} 2 = 1$, 1*23=231 * 23 = 23, $23 \symbol{124} 12 = 31$, and 31/3=1031/3 = 10.

Problem information

Author: Víctor Conchello

Generation: 2026-01-25T11:40:54.546Z

© Jutge.org, 2006–2026.
https://jutge.org