CF2074C.XOR and Triangle

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

XOR and Triangle

This time, the pink soldiers have given you an integer xx (x2x \ge 2).

Please determine if there exists a positive integer yy that satisfies the following conditions.

  • yy is strictly less than xx.
  • There exists a non-degenerate triangle^{\text{∗}} with side lengths xx, yy, xyx \oplus y. Here, \oplus denotes the bitwise XOR operation.

Additionally, if there exists such an integer yy, output any.

^{\text{∗}}A triangle with side lengths aa, bb, cc is non-degenerate when a+b>ca+b \gt c, a+c>ba+c \gt b, b+c>ab+c \gt a.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t20001 \le t \le 2000). The description of the test cases follows.

The only line of each test case contains a single integer xx (2x1092 \le x \le 10^9).

Output

For each test case, print one integer on a separate line. The integer you must output is as follows:

  • If there exists an integer yy satisfying the conditions, output the value of yy (1y<x1 \le y \lt x);
  • Otherwise, output 1-1.

If there exist multiple integers that satisfy the conditions, you may output any.

Note

In the first test case, there exists a non-degenerate triangle with side lengths 33, 55, and 35=63 \oplus 5 = 6. Therefore, y=3y=3 is a valid answer.

In the second test case, 11 is the only possible candidate for yy, but it cannot make a non-degenerate triangle. Therefore, the answer is 1-1.

Samples

7
5
2
6
3
69
4
420
3
-1
5
-1
66
-1
320

在线编程 IDE

建议全屏模式获得最佳体验