Bit
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

Hile wants to play a game with you. First, you can select a number x in the range of .

Then Hile will perform n operations on the number x you select, each of which is of one of the following three types:
  • : change x to , which means bitwise AND.
  • : change x to , which means bitwise OR.
  • : change x to , which means bitwise XOR.
Assume that y is obtained by x after n operations. Hile will ask you q questions. For each question, the operations are fixed, and he will give you a number r --- the range. You should tell her which x  you choose initially to maximize the final y.

输入描述:

The first line of the input contains two integers n, q  --- The number of operations and the number of questions.

The next n lines each line contains two integers t, a --- the operation type and the number.

The next q lines each line contains one integer r --- The number Hile gives you.

输出描述:

Output q lines --- for each r, you should output which x  you choose initially that y is maximize possible.  

.
示例1

输入

复制
3 5
1 2
2 1
3 4
1
2
3
4
5

输出

复制
0
2
3
3
2

说明

In the test case:

If choose y = ((0\ \&\ 2)\ |\ 1) \oplus 4 = 5.

If choose y = ((1\ \&\ 2)\ |\ 1) \oplus 4 = 5.

If choose y = ((2\ \&\ 2)\ |\ 1) \oplus 4 = 7.

If choose y = ((3\ \&\ 2)\ |\ 1) \oplus 4 = 7.

If choose y = ((4\ \&\ 2)\ |\ 1) \oplus 4 = 5.

If choose y = ((5\ \&\ 2)\ |\ 1) \oplus 4 = 5.

When , you can choose  or .

When , you can choose .

When , you can choose  or .