#P1395C. Boboniu and Bit Operations
Boboniu and Bit Operations
No submission language available for this problem.
Description
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers and .
For each (), you're asked to choose a () and let , where denotes the bitwise AND operation. Note that you can pick the same for different 's.
Find the minimum possible , where denotes the bitwise OR operation.
The first line contains two integers and ().
The next line contains integers ().
The next line contains integers ().
Print one integer: the minimum possible .
Input
The first line contains two integers and ().
The next line contains integers ().
The next line contains integers ().
Output
Print one integer: the minimum possible .
Samples
Note
For the first example, we have , , , .Thus , and this is the minimal answer we can get.