#P3293. [SCOI2016] 美味
[SCOI2016] 美味
Description
A restaurant has dishes, numbered . The evaluation value of dish is . There are customers. The -th customer's expected value is , and their preference value is . Therefore, the -th customer considers the deliciousness of dish to be , where denotes the XOR operation.
The -th customer wants to pick the dish they consider the most delicious, i.e., the one with the maximum deliciousness value, but due to price and other factors, they can only choose from dishes through . Please help them find the most delicious dish.
Input Format
The first line contains two integers , the number of dishes and the number of customers.
The second line contains integers , the evaluation value of each dish.
Lines to each contain four integers , indicating the customer's expected value, preference value, and the allowed range of dishes.
Output Format
Output lines, each containing one integer, the maximum deliciousness value chosen by that customer.
4 4
1 2 3 4
1 4 1 4
2 3 2 3
3 2 3 3
4 1 2 4
9
7
6
7
Hint
Constraints.
For of the testdata, it holds that , , (), .
Translated by ChatGPT 5
京公网安备 11011102002149号