QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 2048 MB Total points: 100

#9701. Cat

Statistics

Yen-Jen loves cat very much.

Now, there are $10^{18}$ cats standing in a line, the $i^{th}$ cat's cost value $c_i$ is equal to $i$, the $i^{th}$ cat's index is also equal to $i$.

Now, Yen-Jen wants to buy some cats with continuous index, but he only has $S$ dollars. He wants to buy some cats with continuous indices. In order to buy cat with index $x, x + 1, \dots, y - 1, y$, he needs to spend $x \oplus (x + 1) \oplus \dots \oplus (y - 1) \oplus y$ dollars. $\oplus$ is the bitwise exclusive-or operator.

Now, he wants to ask you $T$ questions. In each question, he has $S$ dollars, and he wants the indices of cats in range $[L, R]$. What's the maximum number of cat that Yen-Jen can buy? If he can't buy any cat, please report $-1$ instead.

Input

The first line of the input file contains one integer $T$ denotes the number of questions that Yen-Jen wants to challenge you.

Then, in the next $T$ lines, each line contains one question. In each line, there are three integers $L, R, S$, which means that Yen-Jen has $S$ dollars, and he wants to buy cats whose indices are in the range $[L, R]$.

  • $1 \le T \le 5 \times 10^5$
  • $1 \le L \le R \le 10^{18}$
  • $0 \le S \le 2 \times 10^{18}$

Output

In each question, output the maximum number of cats that Yen-Jen can buy. If Yen-Jen can't buy any cats, output $-1$ instead.

Sample Input

2
1 1 0
2 2 2

Sample Output

-1
1

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.