Chef has an array A of length N and an integer X.

In one operation, Chef does the following:
Find the smallest element in the current array. Let this be S.
Next, pick any one index i such that A_{i} = S
Finally, replace A_{i} with A_{i} \oplus X

Here \oplus denotes the [bitwise XOR] operation.

For example, if A = [1, 1, 2] and X = 4, then in one move Chef can turn the array into either [5, 1, 2] or [1, 5, 2].

Chef performs this operation exactly Y times. Let B be final array obtained. 

Output the array B in sorted order. Note that under this restriction, the output is unique.

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of two lines of input.
- The first line of each test case contains three space-separated integers N, X, and Y.
- The second line contains N space-separated integers denoting the array A.

------ Output Format ------ 

For each test case, output array B in sorted order.

------ Constraints ------ 

$1 ≤ T ≤ 10^{4}$
$1 ≤ N ≤ 10^{5}$
$1 ≤ Y ≤ 10^{9}$
$1 ≤ A_{i} , X ≤ 2^{30}$
- The sum of $N$ over all test cases won't exceed $10^{5}$.

----- Sample Input 1 ------ 
3
1 6 99
9
3 7 44
1 2 3
5 20 6
5 10 15 20 25

----- Sample Output 1 ------ 
15 
3 5 6 
5 20 25 27 30 

----- explanation 1 ------ 
Test case $1$: The array is initially $[9]$. Since there is only one element, it will be modified in each step. So,
- After the first operation, the array is $[15]$ (since $9 \oplus 6 = 15$)
- After the second operation, the array is $[9]$ (since $15 \oplus 6 = 9$)
- Continuing the above, it can be verified that after $99$ steps, the array is $[15]$.

Test case $3$: The sequence of steps is as follows:
- Initially, the array is $[5, 10, 15, 20, 25]$
- After operation $1$, it is $[17, 10, 15, 20, 25]$
- After operation $2$, it is $[17, 30, 15, 20, 25]$
- After operation $3$, it is $[17, 30, 27, 20, 25]$
- After operation $4$, it is $[5, 30, 27, 20, 25]$
- After operation $5$, it is $[17, 30, 27, 20, 25]$
- After operation $6$, it is $[5, 30, 27, 20, 25]$

Remember to print the output in sorted order.

Difficulty: MEDIUM_HARD

Solutions:
from bisect import bisect_left
from code import interact
from heapq import heapify, heappush, heappop
from collections import deque
from pydoc import plain
import sys
from math import gcd, sqrt, log10, log2, floor, ceil, sqrt
input = sys.stdin.readline

def il():
	return [int(a) for a in input().strip().split()]

def ip():
	return input().strip()

def ii():
	return int(input())

def ot(in_p, *args, e=' '):
	if type(in_p) == list:
		print(*in_p, end=e)
	if type(in_p) == str or type(in_p) == int:
		print(in_p, end=e)
		for l in args:
			print(l, end=e)
	print()

def a_pwr_n(a, n, mod):
	if n == 1:
		return a % mod
	if n % 2 == 0:
		val = a_pwr_n(a, n // 2, mod)
		return val % mod * val % mod
	else:
		return a % mod * a_pwr_n(a, n - 1, mod) % mod

def rg(*ag):
	if len(ag) == 3:
		return range(ag[0], ag[1], ag[2])
	elif len(ag) == 2:
		return range(ag[0], ag[1])
	elif len(ag) == 1:
		return range(ag[0])
	else:
		raise 'invalid input'

def ispal(i, j, st):
	while i <= j:
		if st[i] == st[j]:
			i = i + 1
			j = j - 1
		else:
			return False
	return True
mod = 1000000000 + 7
dx = [-1, -2, 1, 2, 2, -2, -1, 1]
dy = [2, 1, 2, 1, -1, -1, -2, -2]
for _ in range(ii()):
	(N, A, B) = il()
	arr = il()
	m = []
	for j in arr:
		heappush(m, (j, False))
	for k in range(B):
		ele = heappop(m)
		if ele[1]:
			s = B - k
			if s % 2 == 0:
				heappush(m, ele)
			else:
				heappush(m, (ele[0] ^ A, True))
			break
		heappush(m, (ele[0] ^ A, True))
	ans = ''
	while m:
		ans += str(heappop(m)[0]) + ' '
	print(ans)


import heapq
for _ in range(int(input())):
	(n, x, y) = [int(temp) for temp in input().split()]
	a = {}
	a = [int(temp) for temp in input().split()]
	heapq.heapify(a)
	while y:
		min = x ^ a[0]
		if n == 1 or (n == 2 and min < a[1]) or (n > 2 and min < a[1] and (min < a[2])):
			break
		heapq.heappop(a)
		heapq.heappush(a, min)
		y -= 1
	if y % 2:
		a[0] = a[0] ^ x
	for i in range(0, n):
		print(heapq.heappop(a), end=' ')
	print()


for _ in range(int(input())):
	(n, x, y) = map(int, input().split())
	num = list(map(int, input().split()))
	num.sort()
	co = 1
	small = num[0] ^ x
	num[0] = small
	for i in range(1, n):
		char = num[i]
		if char < small and co < y:
			co += 1
			num[i] = char ^ x
			small = min(char ^ x, small)
	num.sort()
	r = y - co
	if r % 2 == 1:
		num[0] = num[0] ^ x
	for i in range(n):
		print(num[i], end=' ')
	print('')


from queue import PriorityQueue
t = int(input())
for _ in range(t):
	(n, x, y) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	q = PriorityQueue()
	for each in arr:
		q.put(each)
	while y:
		smallest = q.get()
		if smallest ^ x > smallest:
			q.put(smallest ^ x)
			y -= 1
		elif y & 1 == 0:
			q.put(smallest)
			break
		else:
			q.put(smallest ^ x)
			break
	while not q.empty():
		print(q.get(), end=' ')
	print()


n = int(input())
for i in range(n):
	(N, X, Y) = (int(x) for x in input().split())
	ls = [int(x) for x in input().split()]
	ls.sort()
	count = 1
	mini = ls[0]
	small = mini ^ X
	ls[0] = small
	for i in range(1, N):
		ch = ls[i]
		if ch < small and count < Y:
			count = count + 1
			ls[i] = ch ^ X
			small = min(ch ^ X, small)
	ls.sort()
	r = Y - count
	if r % 2 == 1:
		ls[0] = ls[0] ^ X
	for i in ls:
		print(i, end=' ')
	else:
		print()


import heapq
from heapq import heappop, heappush, heapify
t = int(input())
for i in range(t):
	(N, X, Y) = map(int, input().strip().split())
	ls = list(map(int, input().strip().split()))
	heapq.heapify(ls)
	prev = -1
	while Y > 0:
		a = heapq.heappop(ls)
		val = a ^ X
		if val == prev:
			heapq.heappush(ls, a)
			break
		heapq.heappush(ls, val)
		prev = a
		Y -= 1
	if Y % 2 == 1:
		a = heapq.heappop(ls)
		val = a ^ X
		heapq.heappush(ls, val)
	ls.sort()
	for j in range(N):
		print(ls[j], end=' ')
	print()


class MinHeap(object):

	def __init__(self):
		self.size = 0
		self.root = 1
		self.heap = list()
		self.heap.append(-1)

	def _ensure_non_empty_heap(self):
		if self.size < self.root:
			raise RuntimeError('Empty heap')

	def _ensure_within_bounds(self, pos):
		if pos > self.size:
			raise RuntimeError('Position {0} is out of bounds of heap whose size is {1}'.format(pos, self.size))

	def _parent(self, pos):
		self._ensure_within_bounds(pos)
		return pos // 2

	def _left_child(self, pos):
		self._ensure_within_bounds(pos)
		return 2 * pos

	def _right_child(self, pos):
		self._ensure_within_bounds(pos)
		return 2 * pos + 1

	def _is_leaf(self, pos):
		self._ensure_within_bounds(pos)
		return 2 * pos > self.size

	def _swap(self, pos_a, pos_b):
		self._ensure_within_bounds(pos_a)
		self._ensure_within_bounds(pos_b)
		(self.heap[pos_a], self.heap[pos_b]) = (self.heap[pos_b], self.heap[pos_a])

	def _heapify(self, pos):
		if self.size == 0:
			return
		if self._is_leaf(pos):
			return
		left_child_pos = self._left_child(pos)
		right_child_pos = self._right_child(pos)
		if right_child_pos > self.size:
			if self.heap[left_child_pos] < self.heap[pos]:
				self._swap(pos, left_child_pos)
			return
		if self.heap[pos] <= min(self.heap[left_child_pos], self.heap[right_child_pos]):
			return
		if self.heap[left_child_pos] < self.heap[right_child_pos]:
			self._swap(pos, left_child_pos)
			self._heapify(left_child_pos)
		else:
			self._swap(pos, right_child_pos)
			self._heapify(right_child_pos)

	def insert(self, value):
		self.size += 1
		self.heap.append(value)
		index = self.size
		while self.heap[index] < self.heap[self._parent(index)]:
			self._swap(index, self._parent(index))
			index = self._parent(index)

	def pop(self):
		self._ensure_non_empty_heap()
		popped = self.heap[self.root]
		self._swap(self.root, self.size)
		self.size -= 1
		self._heapify(self.root)
		self.heap.pop()
		return popped

	def get_min(self):
		self._ensure_non_empty_heap()
		return self.heap[self.root]
T = int(input())
while T:
	T -= 1
	(N, X, Y) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	h = MinHeap()
	for a in A:
		h.insert(a)
	to_insert = -1
	while Y:
		heap_min = h.pop()
		heap_min_xor = heap_min ^ X
		if heap_min_xor < heap_min:
			if Y & 1:
				to_insert = heap_min_xor
			else:
				to_insert = heap_min
			break
		h.insert(heap_min_xor)
		Y -= 1
	if to_insert != -1:
		h.insert(to_insert)
	for i in range(N):
		cur = h.pop()
		print(cur, end=' ')
	print()


from heapq import heapify, heappush, heappop
t = int(input())
for _ in range(t):
	(n, x, y) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	repeat = dict()
	heap = arr[:]
	heapify(heap)
	cnt = 0
	for i in range(y):
		val = heap[0] ^ x
		if val in repeat.keys():
			break
		temp = heappop(heap)
		cnt += 1
		repeat[temp] = 1
		heappush(heap, temp ^ x)
	y = y - cnt
	if y % 2 == 1:
		temp = heappop(heap)
		heappush(heap, temp ^ x)
	heap.sort()
	for i in heap:
		print(i, end=' ')
	print()