intervalxor

Time limit: 0.5s Memory limit: 64MB Input: Output:

Task

Mr. X enjoys solving and especially talking a lot about bitwise operations, even at the New Year's Day party. While drinking with his friends, he came up with the following challenge.

There are qq queries, and in each query you are given a positive integer aia_i (i=0q1i=0\ldots q-1). You are required to answer the following question:

What is the bitwise XOR of the integers in the interval [0,ai0, a_i] and what is the maximum bitwise XOR we can get by removing exactly one integer from that interval?

Your task is to solve the challenge of Mr. X.

Input

The first line of the input contains qq, the number of queries (1q21051 \le q \le 2 * 10^5).

Each of the next qq lines contains a positive integer aia_i, describing a query (1ai1091 \le a_i \le 10^9).

For tests worth 1515 points: 1q,ai10001 \le q, a_i \le 1000
For tests worth 1515 points: 1ai1041 \le a_i \le 10^4
For tests worth 2020 points: 1ai1061 \le a_i \le 10^6 and 1q501 \le q \le 50

Output

You need to write qq lines, the answers to each query. Every line should contain two numbers, namely, the bitwise XOR of the integers in the interval [0,ai0, a_i], and the maximum bitwise XOR we can get by removing one integer from the interval.

stdin

5
29
14
9
12
31

stdout

1 29
15 15
1 9
12 15
0 31

Log in or sign up to be able to send submissions!