You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ pairwise distinct positive integers.

Find $\left\lfloor \frac n 2 \right\rfloor$ different pairs of integers $x$ and $y$ such that:

$x \neq y$;

$x$ and $y$ appear in $a$;

$x~mod~y$ doesn't appear in $a$.

Note that some $x$ or $y$ can belong to multiple pairs.

$\lfloor x \rfloor$ denotes the floor function — the largest integer less than or equal to $x$. $x~mod~y$ denotes the remainder from dividing $x$ by $y$.

If there are multiple solutions, print any of them. It can be shown that at least one solution always exists.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of testcases.

The first line of each testcase contains a single integer $n$ ($2 \le n \le 2 \cdot 10^5$) — the length of the sequence.

The second line of each testcase contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^6$).

All numbers in the sequence are pairwise distinct. The sum of $n$ over all testcases doesn't exceed $2 \cdot 10^5$.


-----Output-----

The answer for each testcase should contain $\left\lfloor \frac n 2 \right\rfloor$ different pairs of integers $x$ and $y$ such that $x \neq y$, $x$ and $y$ appear in $a$ and $x~mod~y$ doesn't appear in $a$. Print the pairs one after another.

You can print the pairs in any order. However, the order of numbers in the pair should be exactly such that the first number is $x$ and the second number is $y$. All pairs should be pairwise distinct.

If there are multiple solutions, print any of them.


-----Examples-----

Input
4
2
1 4
4
2 8 3 4
5
3 8 5 9 7
6
2 7 5 3 4 8
Output
4 1
8 2
8 4
9 5
7 5
8 7
4 3
5 2


-----Note-----

In the first testcase there are only two pairs: $(1, 4)$ and $(4, 1)$. $\left\lfloor \frac 2 2 \right\rfloor=1$, so we have to find one pair. $1~mod~4=1$, and $1$ appears in $a$, so that pair is invalid. Thus, the only possible answer is a pair $(4, 1)$.

In the second testcase, we chose pairs $8~mod~2=0$ and $8~mod~4=0$. $0$ doesn't appear in $a$, so that answer is valid. There are multiple possible answers for that testcase.

In the third testcase, the chosen pairs are $9~mod~5=4$ and $7~mod~5=2$. Neither $4$, nor $2$, appears in $a$, so that answer is valid.

Difficulty: EASY
Tags: Sorting

Implementation

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
def solution(nums, n):
	a = min(nums)
	counter = len(nums) // 2
	i = 0
	for x in nums:
		if x != a:
			print(x, a)
			i += 1
		if i == counter:
			break
t = int(input())
for _ in range(t):
	n = int(input())
	nums = [int(x) for x in input().split()]
	solution(nums, n)


def int_input():
	a = int(input())
	return a

def int_list_input():
	a = list(map(int, input().split()))
	return a

def solve():
	n = int(input())
	arr = int_list_input()
	ans = n // 2
	i = 0
	y = min(arr)
	while ans != 0:
		x = arr[i]
		if x != y:
			print(x, y)
			ans -= 1
		i += 1
for _ in range(int(input())):
	solve()


import sys
input = sys.stdin.readline

def print(x):
	sys.stdout.write(x)
	sys.stdout.write('\n')

def diff(a, b, c, d):
	if len(a) + int(b) > len(c) + int(d):
		return 1
	if len(a) + int(b) < len(c) + int(d):
		return -1
	(a, b, c, d) = (int(a), int(b), int(c), int(d))
	if abs(b - d) > 10:
		return b - d
	if b > d:
		return a * 10 ** (b - d) - c
	return -(c * 10 ** (d - b) - a)

def solve():
	n = int(input())
	arr = list(map(lambda x: int(x), input().split(' ')))
	m = min(arr)
	t = 0
	for a in arr:
		if t >= n // 2:
			break
		if a != m:
			print(f'{a} {m}')
			t += 1
cases = int(input())
for _ in range(cases):
	solve()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = min(l)
	c = n // 2
	i = 0
	while c > 0:
		if l[i] != m:
			print(l[i], m)
			c -= 1
		i += 1


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	for i in range(1, n // 2 + 1):
		print(s[i], s[0])


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	m = min(arr)
	s = set(arr)
	ans = []
	for el in sorted(arr)[1:]:
		if el % m not in s:
			ans.append((el, m))
	for (a, b) in ans[:n // 2]:
		print(a, b)


import sys
import bisect
import math
from collections import deque
input = lambda : sys.stdin.readline().strip()
mod = 10 ** 9 + 7

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = ''
	for i in range(1, n // 2 + 1):
		ans += str(a[i]) + ' ' + str(a[0]) + '\n'
	return ans[:-1]
t = 1
t = int(input())
for _ in range(t):
	print(solve())


for i in range(int(input())):
	n = int(input())
	b = [int(k) for k in input().split()]
	b.sort()
	for k in range(1, n // 2 + 1):
		print(b[k], b[0])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	t = n // 2
	x = min(a)
	i = 0
	for y in range(t):
		if a[i] == x:
			i += 1
		print('%d %d' % (a[i], x))
		i += 1


import sys

def solve():
	inp = sys.stdin.readline
	n = int(inp())
	a = list(map(int, inp().split()))
	b = min(a)
	k = n // 2
	for i in a:
		if i != b:
			print(i, b)
			k -= 1
			if k == 0:
				break

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	m = min(lst)
	i = 0
	inte = False
	while i < n // 2:
		if lst[i] == m:
			i += 1
			inte = True
			continue
		print(lst[i], m)
		i += 1
	if inte:
		print(lst[i], m)


import math

def answer(n, seq):
	(counter, result) = (n, [])
	for i in range(len(seq) // 2):
		print(seq[i], seq[-1])
test = int(input())
for i in range(test):
	n = int(input())
	seq = list(map(int, input().split()))
	seq = sorted(set(seq), reverse=True)
	answer(math.floor(n / 2), seq)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	for i in range(n // 2):
		print(a[n - 1 - i], a[0])
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	x = sorted(map(int, input().split()))
	i = 0
	for k in range(i + 1, i + 1 + n // 2):
		print(x[k], x[i])


from typing import Sequence
T = int(input())
for t in range(T):
	l_of_sequence = int(input())
	sequence = list(map(int, input().split()))
	sequence.sort()
	for i in range(l_of_sequence // 2):
		print(sequence[i + 1], sequence[0])


from collections import Counter
from sys import *
from collections import defaultdict as dd
from math import *

def inp():
	return int(stdin.readline().strip())

def vinp():
	return map(int, stdin.readline().strip().split())

def linp():
	return list(map(int, stdin.readline().strip().split()))

def sinp(n=1):
	if n == 1:
		return stdin.readline().strip()
	elif n == 2:
		return list(stdin.readline().strip())
	else:
		return list(stdin.readline().split())

def pr(*x, end='\n'):
	print(*x, end=end)

def mod(f, val=1000000007):
	return f % val

def csort(c):
	sorted(c.items(), key=lambda pair: pair[1], reverse=True)

def indc(l, n):
	c = {}
	for i in range(n):
		c[l[i]] = c.get(l[i], []) + [i + 1]
	return c
cou = inp()
for _ in range(cou):
	n = inp()
	l = linp()
	m = maxsize
	for i in l:
		m = min(m, i)
	c = n // 2
	for i in l:
		if i != m:
			c -= 1
			pr(i, m)
		if c == 0:
			break
	if c > 0:
		pr(f'{m} {m}\n' * c)


import os
import sys
from io import BytesIO, IOBase
nmbr = lambda : int(input())
lst = lambda : list(map(int, input().split()))

def main():
	for i in range(nmbr()):
		n = nmbr()
		a = sorted(lst())
		p = n - 1
		for i in range(n // 2):
			print(a[p], a[0])
			p -= 1
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for t in range(1):
	main()


def real_input_generator():
	while True:
		yield input()

def example_input_generator(example):
	for line in example.split('\n'):
		yield line
examples = ['4\n2\n1 4\n4\n2 8 3 4\n5\n3 8 5 9 7\n6\n2 7 5 3 4 8', '1\n2\n4 2']

def solve(test_case_num=-1):
	if test_case_num < 0:
		ig = real_input_generator()
	else:
		print('TESTING NOW')
		ig = example_input_generator(examples[test_case_num])
	t = int(next(ig))
	for idx in range(t):
		n = int(next(ig))
		lst = list(map(int, next(ig).split()))
		for pair in solution(n, lst):
			print(' '.join(map(str, pair)))

def solution(n, lst):
	rst = []
	mval = min(lst)
	for k in lst:
		if mval == k:
			continue
			_hy_anon_var_2 = None
		else:
			_hy_anon_var_2 = None
		rst.append([k, mval])
		if len(rst) == n // 2:
			break
			_hy_anon_var_3 = None
		else:
			_hy_anon_var_3 = None
	return rst
solve()


tc = int(input())
for i in range(tc):
	x = int(input())
	list1 = list(map(int, input().split()))
	list1.sort()
	list2 = []
	y = min(list1)
	list1 = list1[1:]
	for i in list1:
		if i % y <= y:
			list2.append(str(i) + ' ' + str(y))
	for i in range(x // 2):
		print(list2[i])


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	minn = min(arr)
	arr.remove(minn)
	for i in range(n // 2):
		print(arr[i], minn)


t = int(input())
for q in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	m = min(arr)
	arr.remove(m)
	for j in range(n // 2):
		print(arr[j], m)


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	for i in range(n // 2):
		print(a[n - i - 1], a[0])
	t = t - 1


import sys
from collections import deque
import math
from bisect import bisect_left
from functools import cmp_to_key

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()

def FACT(n, mod):
	s = 1
	facts = [1]
	for i in range(1, n + 1):
		s *= i
		s %= mod
		facts.append(s)
	return facts[n]

def C(n, k, mod):
	return FACT(n, mod) * pow(FACT(k, mod) * FACT(n - k, mod) % mod, mod - 2, mod) % mod

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	for j in range(1, n // 2 + 1):
		print(l[j], l[0])


t = int(input())
while t:
	t -= 1
	n = int(input())
	ls = list(map(int, input().split()))
	ls.sort()
	y = int(len(ls) / 2)
	x = range(1, y + 1)
	for i in x:
		print(ls[i], ls[0])


for _ in range(int(input())):
	size = int(input())
	array = list(map(int, input().split()))
	array.sort()
	n = size // 2
	j = size - 1
	while n:
		print(array[j], array[0])
		n -= 1
		j -= 1


g = int(input())
for _ in range(g):
	n = int(input())
	l = list(map(int, input().strip().split()))
	l.sort()
	count = 0
	out = False
	si = len(l)
	ch = si // 2
	for i in range(si - 1):
		for j in range(i + 1, si):
			a = l[i] % l[j]
			b = l[j] % l[i]
			lp = si - 1
			fp = 0
			while fp < lp:
				mid = (lp + fp) // 2
				if l[mid] == a:
					break
				elif l[mid] < a:
					fp = mid
				else:
					lp = mid
			else:
				count += 1
				print(l[i], l[j])
			if count == ch:
				out = True
				break
			lp = si - 1
			fp = 0
			while fp < lp:
				mid = (lp + fp) // 2
				if l[mid] == b:
					break
				elif l[mid] < a:
					fp = mid
				else:
					lp = mid
			else:
				print(l[j], l[i])
				count += 1
			if count == ch:
				out = True
				break
		if out:
			break


def getint():
	return [int(i) for i in input().split()]

def get():
	return int(input())

def getstr():
	return [i for i in input().split()]

def S():
	for test in range(int(input())):
		solve()
import math
import itertools as it
import bisect
import time
import collections as ct

def lower_bound(a, x):
	l = -1
	r = len(a)
	while l + 1 != r:
		mid = l + r >> 1
		if a[mid] < x:
			l = mid
		else:
			r = mid
	return r

def upper_bound(a, x):
	l = -1
	r = len(a)
	while l + 1 != r:
		mid = l + r >> 1
		if a[mid] <= x:
			l = mid
		else:
			r = mid
	return r

def solve():
	n = get()
	a = getint()
	a.sort()
	n //= 2
	for i in range(1, n + 1):
		print(a[i], a[0])
S()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mini = min(a)
	ind = a.index(mini)
	temp = a[0]
	a[0] = mini
	a[ind] = temp
	c = n // 2
	for j in range(1, n):
		print(a[j], mini)
		c -= 1
		if c == 0:
			break


t = int(input())
for i in range(t):
	n = int(input())
	A = sorted(list(map(int, input().split())))
	for i in range(n // 2):
		print(A[i + 1], A[0])


import math
t = int(input())
for q in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	mn = min(arr)
	c = 0
	for i in range(len(arr)):
		if arr[i] != mn:
			c += 1
			print(arr[i], mn)
			if c == n // 2:
				break


import sys
from typing import List

def ri():
	return [int(i) for i in input().split()]

def rs():
	return input()[:-1]

def main():
	t = ri()[0]
	for _ in range(t):
		n = ri()[0]
		a = sorted(ri())
		y = a[0]
		for i in range(n // 2):
			print(a[i + 1], y)
input = sys.stdin.readline
main()


mod = 10 ** 9 + 7
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	ans = []
	for i in range(n):
		if a[i] != m:
			ans.append([a[i], m])
		if len(ans) == n // 2:
			break
	for i in range(len(ans)):
		print(ans[i][0], ans[i][1])


for i in range(int(input())):
	lenn = int(input())
	list1 = list(map(int, input().split()))
	list1.sort()
	for i in range(1, lenn // 2 + 1):
		print(list1[i], list1[0])


n = int(input())
for i in range(n):
	b = int(input())
	a = list(map(int, input().split()))
	c = b // 2
	d = min(a)
	a.remove(d)
	for j in range(c):
		print(a[j], d)


def solve_test():
	n = int(input())
	numbers = list(map(int, input().split(' ')))
	numbers.sort()
	minimum = min(numbers)
	for i in range(1, n // 2 + 1):
		print(numbers[i], minimum)

def solve():
	tests = int(input())
	for _ in range(tests):
		solve_test()
solve()


from sys import stdin, stdout

def input():
	return stdin.readline().strip()

def read_int_list():
	return list(map(int, input().split()))

def read_int_tuple():
	return tuple(map(int, input().split()))

def read_int():
	return int(input())

def ans(A):
	N = len(A)
	minA = min(A)
	ret = []
	for a in A:
		if len(ret) == N // 2:
			break
		if a == minA:
			continue
		ret += [(a, minA)]
	for (x, y) in ret:
		print(x, y)
for _ in range(read_int()):
	input()
	A = read_int_list()
	ans(A)


import sys
from collections import defaultdict, deque
from bisect import bisect_left
import math
input = sys.stdin.readline

def inp():
	l = list(map(int, input().split()))
	return l
for _ in range(int(input())):
	(n,) = inp()
	l = inp()
	l.sort()
	for j in range(n // 2):
		print(l[-j - 1], l[0])


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mini = min(arr)
	arr.remove(mini)
	for i in range(n // 2):
		print(f'{arr[i]} {mini}')


from math import ceil, log2, floor, sqrt, gcd
from collections import defaultdict, deque
from bisect import bisect_left
import sys
import os.path
sys.setrecursionlimit(200000)
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r+')
	sys.stdout = open('output.txt', 'w')

def MI():
	return map(int, input().split())
mod = 10 ** 9 + 7

def solve(testcase):
	n = int(input())
	a = list(MI())
	a.sort()
	for i in range(1, n // 2 + 1):
		print(a[i], a[0])
t = int(input())
for _ in range(t):
	solve(_ + 1)


for case in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	x = min(arr)
	arr.remove(x)
	for i in range(n // 2):
		print(arr[i], x)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

def fi():
	return float(input())

def si():
	return input()

def msi():
	return map(str, input().split())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def lsi():
	return list(msi())

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	return x * y // gcd(x, y)
mod = 1000000007

def modInverse(b, m):
	g = gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def ceil2(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def modu(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	if inv == -1:
		return -999999999
	else:
		return inv * a % m
from math import log, factorial, cos, tan, sin, radians, floor, sqrt, ceil, log2
import bisect
import random
import string
from itertools import permutations
from decimal import *
getcontext().prec = 50
abc = 'abcdefghijklmnopqrstuvwxyz'
pi = 3.141592653589793

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		a.sort()
		for i in range(1, n // 2 + 1):
			print(a[i], a[0])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for s in [*open(0)][2::2]:
	a = sorted([int(x) for x in s.split()])
	for i in range(int(len(a) / 2)):
		print(a[i + 1], a[0])


import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
import math
import heapq
import bisect
import collections
import copy

def ceil(a, b):
	return (a + b - 1) // b
BUFSIZE = 8192
inf = float('inf')

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
get = lambda : sys.stdin.readline().rstrip('\r\n')
MOD = 1000000007

def v():
	return list()
for _ in range(int(get())):
	n = int(get())
	l = list(map(int, get().split()))
	l.sort()
	if l[0] == 1:
		for i in range(1, n // 2 + 1):
			print(l[i], 1)
	else:
		for i in range(1, n // 2 + 1):
			print(l[i], l[0])


from math import ceil, log10
import bisect
import math
from collections import defaultdict
from itertools import groupby
from collections import defaultdict, Counter
from heapq import heappop, heappush
from collections import deque
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	k = min(arr)
	c = 0
	i = 0
	while c < n // 2:
		if arr[i] != k:
			print(arr[i], k)
			c += 1
		i += 1


import math
for z in [*open(0)][2::2]:
	m = min((a := z.split()), key=int)
	c = math.floor(len(a) / 2)
	for x in a:
		if x != m:
			print(x, m)
			c -= 1
		if c == 0:
			break


def absent(n, L):
	want = int(n / 2)
	fix = min(L)
	L.remove(fix)
	for i in range(want):
		print(str(L[i]) + ' ' + str(fix))
case = int(input())
for j in range(case):
	n = int(input())
	L = input().split()
	for k in range(n):
		temp = int(L[k])
		L[k] = temp
	absent(n, L)


testNum = int(input())
i = 0
ansNum = []
while i < testNum:
	n = int(input())
	Arr = list(map(int, input().split()))
	b = min(Arr)
	Arr.pop(Arr.index(min(Arr)))
	j = 0
	while j < n // 2:
		ansNum.append((Arr[j], b))
		j += 1
	i += 1
for x in ansNum:
	(a, b) = x
	print(a, b)


t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	dic = {}
	for x in l:
		dic[x] = 1
	ans = []
	x = n // 2
	i = 1
	while x:
		print(l[i], l[0])
		x -= 1
		i += 1
	t -= 1


import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	z = min(arr)
	count = 0
	for i in arr:
		if i == z:
			continue
		print(i, z)
		count += 1
		if count == n // 2:
			break


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	for j in range(1, n // 2 + 1):
		print(arr[j], arr[0])


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	res = []
	minn = min(arr)
	i = 0
	while len(res) < len(arr) // 2:
		if arr[i] == minn:
			i += 1
			continue
		res += [str(arr[i]) + ' ' + str(minn)]
		i += 1
	print('\n'.join(res))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	a.sort()
	for i in range(1, n // 2 + 1):
		print(a[i], m)


for _ in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	for i in range(1, n // 2 + 1):
		print(l[-i], l[0])


kl = int(input())
for kkl in range(kl):
	n = int(input())
	ms = [int(i) for i in input().split()]
	(a, k) = (min(ms), 0)
	for i in range(n // 2):
		if ms[i] == a:
			k += 1
		print(ms[i + k], a)


def main():
	n = int(input())
	x = sorted([int(x) for x in input().split()])
	cnt = 0
	for i in range(1, n):
		if n // 2 == cnt:
			break
		print(x[i], x[0])
		cnt += 1
tests = int(input())
while tests:
	tests -= 1
	main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	c = n // 2
	i = 1
	while c:
		print(l[i], l[0])
		i += 1
		c -= 1


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		arr = [int(num) for num in input().split()]
		mini = min(arr)
		arr.remove(mini)
		for i in range(n // 2):
			print(arr[i], mini)
main()


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
LOGN = 20
INF = 10 ** 9 + 5
MOD = 10 ** 9 + 7

def solve():
	n = int(input())
	A = list(map(int, input().split()))
	need = n // 2
	minv = min(A)
	i = 0
	while need:
		if A[i] != minv:
			print(A[i], minv)
			need -= 1
		i += 1
for _ in range(int(input())):
	solve()


import os
import sys
from io import BytesIO, IOBase
import math as M
import itertools as ITR
from collections import defaultdict as D
from collections import Counter as C
from collections import deque as Q
import threading
from functools import cmp_to_key, lru_cache, reduce
from functools import cmp_to_key as CMP
from bisect import bisect, bisect_left as BL
from bisect import bisect_right as BR
import random as R
import string
import cmath, time
from heapq import heapify, heappop as HPOP
from heapq import heappush as HPUSH
import heapq as H
enum = enumerate
start_time = time.time()
MOD = 1000000007
MA = float('inf')
MI = float('-inf')
d8i = (-1, -1, 0, 1, 1, 1, 0, -1)
d8j = (0, 1, 1, 1, 0, -1, -1, -1)
d4i = (-1, 0, 1, 0)
d4j = (0, 1, 0, -1)

def increase_stack():
	sys.setrecursionlimit(2 ** 32 // 2 - 1)
	threading.stack_size(1 << 27)

def binary(n):
	return bin(n)[2:]

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def maxfactor(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
	if q:
		return q[-1]

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(M.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	l.sort()
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def seive(n):
	a = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	prime[0] = prime[1] = False
	return (a, prime)

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(M.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countchar(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def str_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def lis(arr):
	n = len(arr)
	lis = [1] * n
	maximum = 0
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
				maximum = max(maximum, lis[i])
	return maximum

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def agcd(a, *b):
	for i in b:
		a = gcd(a, i)
	return a

def lcm(a, *b):
	val = a
	gc = a
	for i in b:
		gc = gcd(gc, i)
		val *= i
	return val // gc

def ncr(n, r):
	return M.factorial(n) // (M.factorial(n - r) * M.factorial(r))

def npr(n, r):
	return M.factorial(n) // M.factorial(n - r)

def IF(c, t, f):
	return t if c else f

def YES(c):
	print(IF(c, 'YES', 'NO'))

def Yes(c):
	print(IF(c, 'Yes', 'No'))

def yes(c):
	print(IF(c, 'yes', 'no'))

def JA(a, sep=' '):
	print(sep.join(map(str, a)))

def JAA(a, s='\n', t=' '):
	print(s.join((t.join(map(str, b)) for b in a)))

def PS(a, s=' '):
	print(str(a), end=s)

def I():
	return int(inp())

def F():
	return float(inp())

def LI():
	return list(map(int, inp().split()))

def LF():
	return list(map(float, inp().split()))

def MATI(n):
	return [LI() for i in range(n)]

def MATS(n):
	return [list(inp()) for i in range(n)]

def IV():
	return map(int, inp().split())

def FV():
	return map(float, inp().split())

def LS():
	return list(inp())

def S():
	return inp()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
inp = lambda : sys.stdin.readline().rstrip('\r\n')
TestCases = 1

def solve(test_no):
	n = I()
	q = n // 2
	arr = LI()
	arr.sort()
	for i in range(q):
		print(arr[i + 1], arr[0])

def main():
	flag = 1
	try:
		sys.stdin = open('C:/Users/raavi.manoj/Documents/coding/python/input.txt', 'r')
		sys.stdout = open('C:/Users/raavi.manoj/Documents/coding/python/output.txt', 'w')
	except:
		flag = 0
	t = 1
	if TestCases:
		t = I()
	for test in range(1, t + 1):
		solve(test)
	if flag:
		print('\nTHIS IS A PYTHON OUTPUT FILE')
		print('Time: %.4f seconds' % (time.time() - start_time))
		localtime = time.asctime(time.localtime(time.time()))
		print(localtime)
		sys.stdout.close()
main()


import sys
input = sys.stdin.readline

def answer():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	m = a[0]
	for i in range(n // 2):
		print(a[i + 1], m)
	return
for _ in range(int(input())):
	answer()


from collections import deque as de
import math
import sys
from math import sqrt as sq
from math import floor as fl
from math import ceil as ce
from sys import stdin, stdout
import time
sys.setrecursionlimit(10 ** 7)
from collections import Counter as cnt
from functools import reduce
from itertools import groupby as gb
from bisect import bisect_left as bl, bisect_right as br
from typing import Coroutine

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def __iter__(self):
		return iter(self.data)

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0

	def len(self):
		return len(self.data)
arrStack = My_stack()

class graph:

	def __init__(self):
		self.graphdict = {}

	def add_edge(self, node, neighbor):
		if node not in self.graphdict:
			self.graphdict[node] = [neighbor]
		else:
			self.graphdict[node].append(neighbor)

	def show_edge(self):
		for node in self.graphdict:
			for neighbors in self.graphdict:
				print(node, neighbors)

	def show_graph(self):
		return self.graphdict

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binarytodecimal(n):
	return int(n, 2)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def getProduct(n):
	product = 1
	while n != 0:
		product = product * (n % 10)
		n = n // 10
	return product

def regularBracketsequence(str, arrStack):
	for i in range(len(str)):
		if str[i] == '(':
			arrStack.my_push(str[i])
		elif arrStack.isEmpty():
			return False
		else:
			arrStack.my_pop()
	if arrStack.isEmpty():
		return True
	else:
		return False

def lcm(x, y):
	lcm = x * y // math.gcd(x, y)
	return lcm

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def checkisap(list):
	d = list[1] - list[0]
	for i in range(2, len(list)):
		temp = list[i] - list[i - 1]
		if temp != d:
			return False
	return True

def primes_method5(n):
	out = {}
	sieve = [True] * (n + 1)
	for p in range(2, n + 1):
		if sieve[p]:
			out[p] = 1
			for i in range(p, n + 1, p):
				sieve[i] = False
	return out

def id(i, j, col):
	ans = (i - 1) * col
	ans += j
	return ans

def getSum(n):
	strr = str(n)
	list_of_number = list(map(int, strr.strip()))
	return sum(list_of_number)

def checkperfectsquare(n):
	if ce(sq(n)) == fl(sq(n)):
		return True
	else:
		return False

def combinatrics(n, r):
	num = n
	deno = n - r
	pr = 1
	for i in range(num, deno, -1):
		pr *= i
	an = 1
	for i in range(1, r + 1):
		an *= i
	ans = pr // an
	return ans

def ceildiv(x, y):
	return (x + y - 1) // y

def di():
	return map(int, input().split())

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

def li():
	return list(map(int, input().split()))

def si():
	return list(map(str, input()))

def indict():
	dic = {}
	for (index, value) in enumerate(input().split()):
		dic[int(value)] = int(index)
	return dic

def frqdict():
	dic = {}
	for (index, value) in enumerate(input()):
		if value not in dic:
			dic[value] = 1
		else:
			dic[value] += 1
	return dic
t = ii()
while t:
	t -= 1
	n = ii()
	a = sorted(li())
	for i in range(1, n // 2 + 1):
		print(a[i], a[0])


from __future__ import division, print_function
import math
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def I():
	return int(input())

def lint():
	return list(map(int, input().split()))

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
import itertools
from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)
import sys

def S():
	return list(map(str, input().strip()))

def grid(r, c):
	return [lint() for i in range(r)]
from collections import defaultdict, Counter, deque
import math
import heapq
from heapq import heappop, heappush
import bisect
from math import factorial, inf
from itertools import groupby
from itertools import permutations as comb
mod = 1000000007
MOD = 998244353

def gcd(a, b):
	while b:
		a %= b
		tmp = a
		a = b
		b = tmp
	return a

def lcm(a, b):
	return a // gcd(a, b) * b

def check_prime(n):
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def primefactors(n):
	num = 0
	while n % 2 == 0:
		num += 1
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			num += 1
			n = n // i
	if n > 2:
		num += 1
	return num

def ask(a, b, c):
	print(c, a, b, flush=True)
	n = I()
	return n

def linear_sieve(n):
	is_composite = [False] * n
	prime = []
	for i in range(2, n):
		if not is_composite[i]:
			prime.append(i)
		for j in prime:
			is_composite[i * j] = True
			if i % prime == 0:
				break
	return prime

def dfs(i, p, d):
	(a, tmp) = (0, 0)
	for j in d[i]:
		if j != p:
			a += 1
			tmp += dfs(j, i)
	if a == 0:
		return 0
	return tmp / a + 1

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n // i
	if n > 2:
		l.append(n)
	return l

def binpow(a, b, c):
	res = 1
	a = a % c
	while b > 0:
		if b & 1:
			res = res * a % c
		b = b >> 1
		a = a * a % c
	return res
d = []
primes = []
prim = [0] * (10 ** 6 + 1)

def sieve(n):
	for i in range(n):
		d.append(i)
	for i in range(2, n):
		if d[i] == i:
			prim[i] = 1
			primes.append(i)
		j = 0
		while j < len(primes) and primes[j] <= d[i] and (primes[j] * i < n):
			d[i * primes[j]] = primes[j]
			j += 1

def primeFactors(n):
	factors = []
	while n != 1:
		factors.append(d[n])
		n //= d[n]
	return factors
t = 1
t = I()
for _ in range(t):
	n = I()
	s = lint()
	d = Counter(s)
	s.sort()
	cnt = 0
	for i in range(n):
		for j in range(i + 1, n):
			if s[i] != s[j]:
				tmp = s[j] % s[i]
				if d[tmp] == 0:
					print(s[j], s[i])
					cnt += 1
			if cnt == n // 2:
				break
		if cnt == n // 2:
			break


import os
import sys
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heapify, heappop, heappush, nlargest, nsmallest
from io import BytesIO, IOBase
from types import GeneratorType
BUFSIZE: int = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def modInverse(a, m):
	g = gcd(a, m)
	if g != 1:
		return -1
	else:
		return power(a, m - 2, m)

def power(x, y, m):
	if y == 0:
		return 1
	p = power(x, y // 2, m) % m
	p = p * p % m
	if y % 2 == 0:
		return p
	else:
		return x * p % m

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	ans = set()
	for p in range(2, n + 1):
		if prime[p]:
			ans.add(p)
	return ans
MOD = 1000000007

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		pairs = int(n / 2)
		a.sort()
		for t in range(1, pairs + 1):
			print(a[t], a[0])
main()


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	x = min(a)
	y = n // 2
	i = 0
	while y > 0:
		if a[i] != x:
			print(*[a[i], x])
			y -= 1
		i += 1
for _ in range(int(input())):
	solve()


def solve():
	n = int(input())
	A = [int(x) for x in input().split()]
	mn = min(A)
	need = n // 2
	for x in A:
		if x != mn and need > 0:
			print(x, mn)
			need -= 1
t = int(input())
for _ in range(t):
	solve()


import sys
import io, os
input = sys.stdin.buffer.readline
N = 10 ** 6
t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	ans = []
	A.sort()
	y = A[0]
	for i in range(1, n):
		x = A[i]
		ans.append((x, y))
	for i in range(n // 2):
		print(*ans[i])


t = int(input())
for q in range(0, t):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	requirement = n // 2
	temp = 1
	for i in range(0, requirement):
		print(li[temp], li[0])
		temp += 1


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	for i in range(1, n // 2 + 1):
		print(l[i], l[0])


import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

def get_ints_in_variables():
	return map(int, sys.stdin.readline().strip().split())

def get_int():
	return int(sys.stdin.readline())

def get_ints_in_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

def get_string():
	return sys.stdin.readline().strip()

def myceil(x, y):
	return (x + y - 1) // y

def Solution():
	for _ in range(get_int()):
		n = get_int()
		arr = sorted(get_ints_in_list())
		y = arr[0]
		for i in range(n // 2):
			print(arr[i + 1], y)

def main():
	Solution()
main()


q = int(input())
for _ in range(q):
	n = int(input())
	a = sorted([int(a) for a in input().split()])
	count = 0
	for i in range(1, n):
		print(a[i], a[0])
		count += 1
		if count == n // 2:
			break


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	a.sort()
	ans = []
	cnt = 0
	for i in range(n - 1, -1, -1):
		ans.append([a[i], a[0]])
		if len(ans) == n // 2:
			break
	for i in ans:
		print(*i)


for _ in range(int(input())):
	n = int(input())
	n = n // 2
	a = list(map(int, input().split()))
	a = sorted(a)
	y = a[0]
	i = 1
	while i < n + 1:
		print(a[i], y)
		i += 1


from math import *
t = int(input())
for i in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	lis.sort()
	for i in range(1, n // 2 + 1):
		print(lis[i], lis[0])


for _ in range(int(input())):
	n = int(input())
	a = set([int(i) for i in input().split()])
	m = min(a)
	a -= {m}
	i = 0
	while i < n // 2 and a:
		p = a.pop()
		i += 1
		print(p, m)
	if i < n // 2:
		print(1 / 0)


for i in range(int(input())):
	n = int(input())
	a = [int(j) for j in input().split()]
	pair = n // 2
	p = min(a)
	for j in a:
		if j != p and pair:
			print(j, p)
			pair -= 1
		if pair == 0:
			break


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		temp = min(a)
		a.remove(temp)
		for i in range(n // 2):
			print(a[i], temp)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = set()
	s = set(a)
	a.sort()
	for i in range(n):
		j = i + 1
		while len(ans) < n // 2 and j < n:
			if a[i] != a[j] and a[i] % a[j] not in s:
				ans.add((a[i], a[j]))
			if a[i] != a[j] and a[j] % a[i] not in s:
				ans.add((a[j], a[i]))
			j += 1
		if len(ans) == n // 2:
			break
	for i in ans:
		print(i[0], i[1])


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	mn = min(arr)
	arr.remove(mn)
	for i in range(n // 2):
		print(arr[i], mn)
for _ in range(int(input())):
	main()


import math

def solve(n, A):
	A.sort()
	mi = min(A)
	ans = []
	cnt = math.floor(n / 2)
	for a in A[1:cnt + 1]:
		ans.append((a, mi))
	return ans

def main():
	ans = []
	t = int(input())
	for _ in range(t):
		n = int(input())
		A = list(map(int, input().split(' ')))
		ans.append(solve(n, A))
	for a in ans:
		for (x, y) in a:
			print(f'{x} {y}')
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	min_val = min(a)
	req = n // 2
	for i in a:
		if i == min_val:
			continue
		else:
			print(i, min_val)
			req -= 1
			if req == 0:
				break


t = int(input())

def find_pairs(a, n):
	pairs = []
	b = min(a)
	for i in a:
		if i == b:
			continue
		pairs.append((i, b))
		if len(pairs) >= n // 2:
			break
	return pairs
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = find_pairs(a, n)
	for i in ans:
		print(i[0], i[1])


import string
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	for i in range(n // 2):
		print(a[i + 1], a[0])


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
from collections import deque, Counter
from bisect import bisect_left, bisect_right
from math import ceil, log2, sqrt, gcd
from itertools import permutations

class DisjointSetUnion:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n

	def find(self, a):
		acopy = a
		while a != self.parent[a]:
			a = self.parent[a]
		while acopy != a:
			(self.parent[acopy], acopy) = (a, self.parent[acopy])
		return a

	def union(self, a, b):
		(a, b) = (self.find(a), self.find(b))
		if a != b:
			if self.size[a] < self.size[b]:
				(a, b) = (b, a)
			self.num_sets -= 1
			self.parent[b] = a
			self.size[a] += self.size[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		a.sort()
		for i in range(n // 2):
			print(a[1 + i], a[0])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	for i in range(n // 2):
		print(l[i + 1], l[0])


import sys
t = int(sys.stdin.readline())
ans = []
for _ in range(t):
	n = int(sys.stdin.readline())
	m = n // 2
	nums = sorted(map(int, sys.stdin.readline().split()))
	for i in range(m):
		ans.append(f'{nums[-i - 1]} {nums[0]}')
print('\n'.join(ans))


for t in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	m = min(a)
	a = [i for i in a if i != m]
	a = a[:n // 2]
	for i in a:
		print(i, m)


import sys
from math import sqrt, gcd
from collections import deque
sys.setrecursionlimit(10 ** 8)
I = lambda : int(input())
S = lambda : input().strip()
M = lambda : map(int, input().strip().split())
L = lambda : list(map(int, input().strip().split()))
mod = 1000000007
for i in range(I()):
	n = I()
	l = L()
	l.sort()
	d = {i: 1 for i in l}
	c = n // 2
	i = 0
	while c > 0:
		j = i + 1
		while c > 0 and j < n:
			if l[j] % l[i] not in d:
				print(l[j], l[i])
				c -= 1
			j += 1
		i += 1


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	for i in range(n // 2):
		(x, y) = (a[i], a[-1])
		print(x, y)


import os
import sys
from bisect import *
from io import BytesIO, IOBase
from typing import overload

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = int(1000000000.0 + 7)
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	a = sorted(array())
	ans = []
	have = set()
	for i in range(1, n):
		ans.append((a[i], a[0]))
	for i in ans[:n // 2]:
		print(*i)


import math
t = int(input())
while t >= 1:
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	numberOfPairs = math.floor(n / 2)
	for i in range(numberOfPairs):
		print('{} {}'.format(x[i + 1], x[0]))
	t = t - 1


import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def LI1():
	return list(map(int1, sys.stdin.readline().split()))

def LLI1(rows_number):
	return [LI1() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
inf = 4294967295
md = 10 ** 9 + 7

def solve():
	n = II()
	aa = LI()
	aa.sort()
	for a in aa[1:1 + n // 2]:
		print(a, aa[0])
for testcase in range(II()):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	for j in range(1, n // 2 + 1):
		print(lst[j], lst[0])


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	a = n // 2
	ans = []
	arr.sort(reverse=True)
	for i in range(n // 2):
		print(arr[i], arr[-1])


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	for i in range(1, n // 2 + 1):
		sys.stdout.write(str(l[i]) + ' ' + str(l[0]) + '\n')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	y = min(a)
	c = 0
	for x in a:
		if x != y:
			print(x, y)
			c += 1
		if c == n // 2:
			break


for _ in range(int(input())):
	n = int(input())
	a = sorted([int(i) for i in input().split()])
	a.reverse()
	for i in range(n // 2):
		print(a[i], a[-1])


import sys
from sys import stdin, stdout
from math import ceil, floor, sqrt, log, log2, log10
from collections import Counter
int_max = float('inf')
int_min = -float('inf')
mod = 10 ** 9 + 7
ANS = []
input = stdin.readline

def solve():
	pass
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	j = 1
	for i in range(n // 2):
		print(arr[j], arr[0])
		j += 1


from collections import Counter, deque
import math
from random import randint
from bisect import bisect
import sys
import re
import copy
from decimal import Decimal, getcontext
getcontext().prec = 32
MOD = 1000000007
MAX = sys.maxsize
MIN = -sys.maxsize
prime = []

class get:

	def int():
		return list(map(int, input().split()))

	def str():
		return input().split()

	def float():
		return list(map(float, input().split()))

	def map():
		return map(int, input().split())

def sqrt(x):
	return int(math.sqrt(x)) + 1

def gcd(*args):
	result = args[0]
	for item in args:
		result = math.gcd(result, item)
	return result

def LCM(a, b):
	return a * b // math.gcd(a, b)

def isPrime(n):
	if n == 1:
		return False
	for i in range(2, sqrt(n)):
		if n % i == 0:
			return False
	return True

def solve():
	n = int(input())
	a = get.int()
	a.sort()
	for i in range(n // 2):
		print(a[i + 1], a[0])
for _ in range(int(input())):
	solve()


x = int(input())
for i in range(x):
	b = int(input())
	a = input().split()
	d = dict()
	for j in range(b):
		d[int(a[j])] = 1
	z = []
	count = 0
	p = []
	for key in d:
		z.append(key)
	z.sort()
	ans = b // 2
	l = 0
	while count < ans:
		for k in range(len(z) - 1, l, -1):
			if z[k] % z[l] not in d and count < ans:
				p.append([z[k], z[l]])
				count += 1
			if count >= ans:
				break
		l += 1
	for item in range(len(p)):
		print(p[item][0], p[item][1])


import math
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	for j in range(1, n // 2 + 1):
		print(l[j], '', l[0])


import random
from collections import Counter, defaultdict
from copy import deepcopy as dc
import math
try:
	t = int(input())
	for tt in range(1, t + 1):
		n = int(input())
		a = list(map(int, input().split()))
		a.sort()
		for i in range(1, 1 + n // 2):
			print(a[i], a[0])
except EOFError as e:
	pass


import sys
from bisect import bisect_left as lb
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue as pq
from math import gcd
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
lii = lambda : list(map(int, list(ip())))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
mod = 10 ** 9 + 7
mod1 = 998244353
for _ in range(ii()):
	n = ii()
	a = il()
	t = 0
	for i in a:
		if i == 1:
			t = 1
			break
	if t:
		x = 0
		for i in a:
			if x == n // 2:
				break
			if i != 1:
				print(i, 1)
				x += 1
		continue
	x = min(a)
	t = 0
	for i in a:
		if t == n // 2:
			break
		if i != x:
			print(i, x)
			t += 1


n = int(input())
for i in range(n):
	n1 = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	cnt = 0
	for j in range(1, len(a)):
		print(a[j], a[0])
		cnt += 1
		if cnt == len(a) // 2:
			break


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	l = sorted(list(map(int, input().split())))
	for i in range(int(n / 2)):
		print(l[-(i + 1)], l[0])


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split(' ')))[:n]
	lst_1 = sorted(lst)
	x = n // 2
	y = lst_1[0]
	cou = 0
	for i in lst_1[1:]:
		if cou < x:
			print(i, y)
			cou += 1


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	for i in range(len(arr) // 2):
		print(arr[i + 1], arr[0])


import sys
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def solve():
	n = int(input())
	nums = list(map(int, input().split()))
	nums.sort()
	nums_set = set(nums)
	count = 0
	for i in range(n):
		for j in range(i + 1, n):
			if nums[j] % nums[i] not in nums_set:
				count += 1
				print(nums[j], nums[i])
			if count >= n // 2:
				return
T = int(input())
for t in range(T):
	solve()


import sys
for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	A = sorted(A)
	for i in range(1, n // 2 + 1):
		print(A[i], A[0])


import sys
import bisect
from bisect import bisect_left as lb
from bisect import bisect_right as rb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
sys.setrecursionlimit(3 * 10 ** 5)
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs2(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
a = []
(n, k) = (0, 0)
b = []
vis = []
tot = 0
time = []
time1 = []
adj = []
mx = -1
eps = 1e-07
x = 0
pref = []
lvl = []
gp = []
ans = []
f = 0
w = []

def update_it(bit, i, val):
	n = len(bit)
	while i < n:
		bit[i] += val
		i += i & -i

def get_ans(bit, i):
	n = len(bit)
	tot = 0
	while i > 0:
		tot += bit[i]
		i -= i & -i
	return tot

def dfs(i, prod, rem, n):
	if rem == 0:
		while i < len(n):
			prod *= int(n[i])
			i += 1
		return prod
	if i == len(n):
		return prod
	mx = 0
	for j in range(9 - int(n[i])):
		mx = max(dfs(i + 1, (int(n[i]) + min(j, rem)) * prod, rem - min(j, rem), n), mx)
	return mx

def hnbhai(tc):
	n = sb()
	a = sd()
	a.sort()
	if 1 in a:
		tot = n // 2
		while tot > 0:
			print(a[-1], 1)
			a.pop()
			tot -= 1
		return
	mn = min(a)
	tot = n // 2
	while tot > 0:
		print(a[-1], mn)
		tot -= 1
		a.pop()
	return
for _ in range(sb()):
	hnbhai(_ + 1)


t = int(input())
for I in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	y = min(a)
	k = n // 2
	for i in a:
		if y == i:
			continue
		print(i, y)
		k -= 1
		if k == 0:
			break


from bisect import bisect_left

def printPairs(n, a):
	a.sort()
	count = 0
	breakFlag = False
	for i in range(n - 1, -1, -1):
		for j in range(i):
			index = bisect_left(a, a[i] % a[j])
			if index != n and a[index] == a[i] % a[j]:
				continue
			print(a[i], a[j])
			count += 1
			if count >= n // 2:
				breakFlag = True
				break
		if breakFlag:
			break

def printPairs1(n, a):
	minEle = min(a)
	count = 0
	for i in range(n):
		if a[i] != minEle:
			print(a[i], minEle)
			count += 1
			if count >= n // 2:
				break

def main():
	no_of_test_cases = int(input().strip())
	for i in range(no_of_test_cases):
		n = int(input().strip())
		a = list(map(int, input().strip().split()))
		printPairs1(n, a)
main()


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	mn = min(l)
	x = n // 2
	cnt = 0
	i = -1
	while cnt != x:
		i += 1
		if l[i] != mn:
			print(l[i], mn)
			cnt += 1


t = int(input())
for k in range(t):
	n = int(input())
	arr = []
	inp = input().split()
	even = []
	odd = []
	for i in inp:
		arr.append(int(i))
	arr.sort()
	from collections import defaultdict
	arr1 = defaultdict(int)
	for i in arr:
		arr1[i] = 1
	count = 0
	result = []
	curr = True
	for i in range(len(arr)):
		for j in range(len(arr) - 1, i, -1):
			p = arr[j] % arr[i]
			if arr1[p] == 0:
				result.append([arr[j], arr[i]])
				count += 1
				if count == n // 2:
					curr = False
					break
		if curr == False:
			break
	for i in result:
		print(i[0], i[1])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	t = n // 2
	i = 0
	while t > 0:
		if a[i] == m:
			i += 1
			continue
		else:
			t -= 1
			print(a[i], m)
			i += 1


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	for i in range(1, n // 2 + 1):
		print(l[i], l[0])


t = int(input())
for i in range(0, t):
	b = int(input())
	c = list(map(int, input().split()))
	c.sort()
	for g in range(0, b // 2):
		print(c[g + 1], c[0])


t = int(input())
for s in range(t):
	n = int(input())
	X = list(map(int, input().split()))
	X.sort()
	ans = []
	for j in range(1, n, 1):
		ans.append([X[j], X[0]])
	for j in range(n // 2):
		print(*ans[j])


a = int(input())
for i in range(a):
	n = int(input())
	V = list(map(int, input().split()))
	M = min(V)
	I = 0
	for i in V:
		if I == n // 2:
			break
		if i != M:
			print(i, M)
			I += 1


def pair(nums):
	nums.sort()
	results = []
	for i in range(1, len(nums) // 2 + 1):
		results.append(f'{nums[i]} {nums[0]}')
	return '\n'.join(results)
(inp, results) = (int(input()), [])
for _ in range(inp):
	_ = input()
	results.append(pair(list(map(int, input().split()))))
print(*results, sep='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	(*a,) = map(int, input().split())
	a.sort()
	y = a[0]
	for i in range(1, n // 2 + 1):
		print(a[i], y)


import sys
input = sys.stdin.readline
t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	li.sort()
	for i in range(1, 1 + n // 2):
		print(li[i], li[0])


t = int(input())
for i in range(0, t):
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	for i in range(0, n // 2):
		print(l[i + 1], end=' ')
		print(l[0])


T = int(input())
for testcase in range(1, T + 1):
	n = int(input())
	a = list(map(int, input().split()))
	x = min(a)
	i = 0
	count = n // 2
	while count > 0:
		v = a[i]
		if v != x:
			print(v, x)
			count -= 1
		i += 1


t = int(input())
for m in range(t):
	n = int(input())
	int_list = list(map(int, input().split()))
	int_list.sort()
	sum = 0
	y = int_list[0]
	for i in range(n):
		x = int_list[i + 1]
		mod = x % y
		sum = sum + 1
		print(x, y)
		if sum >= n // 2:
			break


for _ in range(int(input())):
	N = int(input())
	arr = sorted(list(map(int, input().split())))
	for i in range(1, N // 2 + 1):
		print(arr[i], arr[0])


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	m = min(a)
	ans = []
	i = -1
	while len(ans) < n // 2:
		i += 1
		if a[i] == m:
			continue
		ans.append((a[i], m))
	for v in ans:
		print(*v)


for test in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	mini = min(arr)
	k = n // 2
	i = 0
	while k > 0:
		if arr[i] == mini:
			i += 1
		else:
			print(arr[i], mini)
			k -= 1
			i += 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mn = min(a)
	ans = 0
	i = 0
	while ans < n // 2:
		k = a[i]
		i += 1
		if k == mn:
			continue
		print(k, mn)
		ans += 1


import sys
import os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	sys.stderr = open('error.txt', 'w')
depth = 1000000
mod = 1000000007
lim = mod * mod
sys.setrecursionlimit(depth)
linp = lambda : list(minp())
minp = lambda : map(int, input().split())
from math import inf, ceil, sqrt, log2, gcd
from collections import defaultdict, deque
dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]

def expo(a, b):
	if not b:
		return 1
	v = expo(a, b // 2)
	v = v * v % mod
	if b % 2:
		v = v * a % mod
	return v

def modinv(a, b):
	d = expo(b, mod - 2)
	v = a * d % mod
	return v

def checkPrime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	for i in range(3, int(sqrt(n)) + 1, 2):
		if n % i == 0:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	a = sorted(linp())
	(c, i) = (0, 1)
	while c < n // 2:
		print(a[i], a[0])
		i += 1
		c += 1


def so():
	n = int(input())
	arr = [int(i) for i in input().split()]
	mn = min(arr)
	k = 0
	i = 0
	while k < n // 2 and i < n:
		if arr[i] != mn:
			print(arr[i], mn)
			k += 1
		i += 1
tst = int(input())
for i in range(tst):
	so()


t = int(input())
for i in range(t):
	n = int(input())
	p = n // 2
	a = list(map(int, list(input().split())))
	d = {}
	a = sorted(a)[::-1]
	for i in a:
		d[i] = 1
	x = a[-1]
	count = 0
	for i in a[0:n - 1]:
		count = count + 1
		if count <= p:
			print(i, x)
		else:
			break


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, functools, copy, random
from functools import reduce
import operator
inf = float('inf')
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def LS():
	return input().split()

def endl():
	return print('\n')

def lcm(a, b):
	return a * b // fractions.gcd(a, b)

def grayCode(n):
	return n ^ n >> 1
sys.setrecursionlimit(20000)
graph = collections.defaultdict(list)
grid = []
visited = set()
ways = ['D', 'U', 'R', 'L']
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]

def find(i):
	if par[i] != i:
		par[i] = find(par[i])
	return par[i]

def union(a, b):
	a = find(a)
	b = find(b)
	if a == b:
		return False
	par[a] = b
	return True

def initGraph(m):
	for _ in range(m):
		(u, v) = LI()
		graph[u - 1].append(v - 1)
		graph[v - 1].append(u - 1)
	return graph

def initGraphW(m):
	for _ in range(m):
		(a, b, c) = LI()
		graph[a - 1].append((b - 1, c))
		graph[b - 1].append((a - 1, c))

def initGrid(h, w):
	for i in range(h):
		s = S()
		grid.append(list(s))
	return grid

def soe(limit):
	a = [True] * limit
	a[0] = a[1] = False
	for (i, isprime) in enumerate(a):
		if isprime:
			yield i
			for n in range(i * i, limit, i):
				a[n] = False
	return a
for _ in range(I()):
	n = I()
	cnt = n // 2
	a = LI()
	a.sort()
	mn = min(a)
	a.remove(mn)
	chk = set(a)
	for i in range(n - 1):
		if cnt == 0:
			break
		if mn % a[i] not in chk and a[i] != mn:
			print(a[i], mn)
			cnt -= 1


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	for i in range(n // 2):
		print(a[i], a[-1])


for _ in range(int(input())):
	num = int(input())
	ans = list(map(int, input().split()))
	mn = min(ans)
	ptr = num // 2
	idx = 0
	while ptr > 0:
		if ans[idx] == mn:
			idx += 1
			continue
		else:
			ptr -= 1
			print(ans[idx], mn)
			idx += 1


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	lis_min = min(lis)
	lis.remove(min(lis))
	for i in range(n // 2):
		print(lis[i], lis_min)


t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	for r in range(1, n // 2 + 1):
		print(a[r], a[0])


tc = int(input())
for i in range(tc):
	n = int(input())
	li = list(map(int, input().split()))
	count = 0
	mn = min(li)
	for i in range(n):
		if count == n // 2:
			break
		if li[i] != mn:
			print(li[i], end=' ')
			print(mn)
			count += 1


def func():
	n = int(input())
	l = list(map(int, input().split()))
	k = min(l)
	l1 = 0
	c = 0
	while l1 != int(n // 2):
		if l[c] != k:
			print(l[c], k)
			c += 1
			l1 += 1
		else:
			c += 1
t = int(input())
for i in range(t):
	func()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ind = arr.index(min(arr))
	c = 0
	j = 0
	for i in range(n // 2):
		if j == ind:
			j += 1
		print(arr[j], arr[ind])
		j += 1


t = int(input())
for idx in range(t):
	n = int(input())
	arr = []
	data = input().split(' ')
	for i in range(n):
		arr.append(int(data[i]))
	arr.sort()
	for i in range(1, n // 2 + 1):
		print(arr[i], arr[0])