AlgoUniversity
  • Go Back
Discussion
Maximum Xor :

Author

Ujjwal Srivastava

Difficulty Level : Medium

Submissions : 209

Asked In : Pine-Labs

Marks :30

: 6 | : 0

Amaru and Kapkan were playing Rainbow 6 Slege in which Kapkan strategically placed $$$N$$$ bombs all over the map.

Each bomb has 3 numbers associated to it $$$X,L$$$ and $$$R$$$ and can only be defused by finding the maximum value of $$$(X \bigoplus Y)$$$, where $$$\bigoplus$$$ the bitwise xor operation between $$$X$$$ and $$$Y$$$ and $$$Y$$$ can be any number between $$$[L,R].$$$

Amaru is a dumb player so can you help him by winning by finding the maximum value of $$$(X \bigoplus Y)$$$ for all $$$N$$$ bombs?

Input

The first line contains an integer $$$N$$$. The next $$$N$$$ line contains 3 integers $$$X, L$$$ and $$$R$$$.$$$(1 \le N \le 5000)$$$$$$(1 \le L,R \le 10^9)$$$$$$(1 \le X \le 10^9).$$$

Output

For each query output a single integer the maximum XOR value.

Examples

Input
1
4 1 4
Output
7
Input
2
2 2 4
3 1 9
Output
6
11

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.