#P1936D. Bitwise Paradox
Bitwise Paradox
Description
You are given two arrays and of size along with a fixed integer .
An interval is called a good interval if , where denotes the bitwise OR operation. The beauty of a good interval is defined as .
You are given queries of two types:
- "1 i x": assign ;
- "2 l r": find the minimum beauty among all good intervals satisfying . If there is no suitable good interval, output instead.
Please process all queries.
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains two integers and (, ).
The second line of each testcase contains integers ().
The third line of each testcase contains integers ().
The fourth line of each testcase contains one integer ().
The -th of the following lines contains the description of queries. Each line is of one of two types:
- "1 i x" (, ;
- "2 l r" ().
It is guaranteed that both the sum of and the sum of over all test cases do not exceed .
For each test case, output the answers for all queries of the second type.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains two integers and (, ).
The second line of each testcase contains integers ().
The third line of each testcase contains integers ().
The fourth line of each testcase contains one integer ().
The -th of the following lines contains the description of queries. Each line is of one of two types:
- "1 i x" (, ;
- "2 l r" ().
It is guaranteed that both the sum of and the sum of over all test cases do not exceed .
Output
For each test case, output the answers for all queries of the second type.
Note
In the first test case, , , and .
The first query is of the second type and has and . The largest interval available is , and its bitwise OR is which is less than . Thus, no good interval exists.
The second query asks to change to , so becomes .
The third query is of the second type and has and . There are three possible intervals: , , and . However, , . So only the last interval is good: it has . The answer is thus .
The fourth query is of the second type and has and . There are three good intervals: , , and . Their beauty is , , correspondingly. The answer is thus .
In the second test case, , , and .
The first query has and . The only good intervals are: , , . Their beauty is , , correspondingly. The answer is thus .