Given an integer $x$, find two non-negative integers $a$ and $b$ such that $(a \wedge b) + (a \vee b) = x$, where $\wedge$ is the bitwise AND operation and $\vee$ is the bitwise OR operation.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first and only line of each test case contains a single integer $x$.

-----Output-----
If there is no valid pair $(a, b)$, print a single line containing the integer $-1$. Otherwise, print a single line containing two space-separated integers $a$ and $b$.
If there are multiple solutions, you may print any one of them.

-----Constraints-----
- $1 \le T \le 10^5$
- $1 \le x \le 10^{18}$

-----Subtasks-----
Subtask #1 (30 points):
- $1 \le T \le 200$
- $1 \le x \le 200$
Subtask #2 (70 points): original constraints

-----Example Input-----
2
1
8

-----Example Output-----
0 1
5 3

Source: codechef | Difficulty: EASY
Tags: Bit manipulation

Mathematics


Solutions:
for t in range(int(input())):
	x = int(input())
	if x % 2 == 1:
		print(x // 2, x // 2 + 1)
	else:
		print(x // 2 + 1, x // 2 - 1)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	if n % 2 is 0:
		a = n // 2 + 1
		b = n // 2 - 1
	else:
		a = n // 2
		b = n // 2 + 1
	print(a, b)


t = int(input())
for i in range(t):
	x = int(input())
	if x > 3:
		print(f'{x - 3} {3}')
	elif x == 1:
		print('0 1')
	elif x == 2:
		print('0 2')
	elif x == 3:
		print('1 2')
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	if n % 2 == 0:
		print(n // 2 - 1, n // 2 + 1)
	else:
		print(n // 2, n // 2 + 1)


T = int(input())
for _ in range(T):
	x = int(input())
	p = x // 2
	if x % 2 == 1:
		print(p, p + 1)
	else:
		print(p + 1, p - 1)


n = int(input())
for _ in range(n):
	a = int(input())
	if a % 2 == 0:
		f = a // 2 - 1
		s = a - f
	else:
		f = a // 2
		s = a - f
	print(f, s)