Broken Address Bus
문제
The memory in Juku's computer has cells, addressed by numbers . To read the value from a cell, you first have to put the cell's address on the address bus. The address bus consists of parallel wires---one for each bit of the address. E.g., to read the value at the address , you first write out in binary------and then put voltage on wires , , and . To read from the address , you don't put voltage on any of the wires.
However, some wires are broken---when you put voltage on any of them, the memory chip will not register it. E.g, if the wire is broken, you cannot read from the address because it requires voltage on the wire . On the other hand, you still can read from .
Given the contents of the memory and the set of all intact wires, compute the sum of all the values you can read.
입력
The first line of input contains (), the number of values in memory, and (), the number of queries. The next lines contain the values in memory cells, from to , one per line. Each value is a non-negative integer not larger than . The last lines contain the queries. Each query gives the address () that you get when you put voltage on all the wires that are not broken.
출력
The output must contain lines, each with the answer to the corresponding query: the sum of the values that can be read from the memory if the set of working address bus wires is as given in the query parameter .
힌트
In the query '0', all wires are broken, and only the value at address is readable.
In the query '15', the first wires are working and all values are readable.
In the last query, only the values and are readable.
예제
예제 1
3 3 10 7 1 0 15 2
10 18 11