Given an array A of length N, your task is to find the element which repeats in A maximum number of times as well as the corresponding count. In case of ties, choose the smaller element first.

-----Input-----
First line of input contains an integer T, denoting the number of test cases. Then follows description of T cases. Each case begins with a single integer N, the length of A. Then follow N space separated integers in next line.  Assume that 1 <= T <= 100, 1 <= N <= 100 and for all i in [1..N] : 1 <= A[i] <= 10000

-----Output-----
For each test case, output two space separated integers V & C. V is the value which occurs maximum number of times and C is its count.

-----Example-----
Input:
2
5
1 2 3 2 5
6
1 2 2 1 1 2

Output:
2 2
1 3

Description:
In first case 2 occurs twice whereas all other elements occur only once. 
In second case, both 1 and 2 occur 3 times but 1 is smaller than 2.

Source: codechef | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
t = input()
a = [0 for i in range(10001)]
i = 0
while i < int(t):
	n = input()
	k = input()
	assert len(k.split(' ')) == int(n)
	for each in k.split(' '):
		a[int(each)] += 1
	V = 0
	C = a[V]
	for j in range(10001):
		if C < a[j]:
			V = j
			C = a[V]
		a[j] = 0
	i += 1
	print(V, C)


import sys

def main():
	s = sys.stdin.readline
	for t in range(int(s())):
		n = int(s())
		A = list(map(int, s().split()))
		save = {}
		for i in A:
			if i in save:
				save[i] += 1
			else:
				save[i] = 1
		g = max(save, key=save.get)
		now = []
		for num in save:
			if save[num] == save[g]:
				now.append(num)
		now = sorted(now)
		print(now[0], save[g])

def __starting_point():
	main()
__starting_point()


import fileinput

def CountMax(nA, A):
	hT = {}
	for n in A:
		if n not in hT:
			hT.setdefault(n, 1)
		else:
			hT[n] += 1
	vals = [(pair[0], pair[1]) for pair in hT.items()]
	vals.sort(key=lambda p: p[0])
	return max(vals, key=lambda p: p[1])

def main():
	f = fileinput.FileInput()
	r = f.readline()
	if r == '':
		return 0
	else:
		nT = int(r)
	while nT > 0:
		nA = int(f.readline())
		A = list(map(int, f.readline().strip().split(' ')))
		result = CountMax(nA, A)
		print(result[0], result[1])
		nT = nT - 1
	return 0

def __starting_point():
	main()
__starting_point()


from sys import stdin as I
from collections import defaultdict
ints = lambda : [int(s) for s in I.readline().split()]
T = ints()[0]
while T:
	T -= 1
	n = ints()
	c = defaultdict(int)
	for x in ints():
		c[x] += 1
	rv = (0, 0)
	for (val, ct) in list(c.items()):
		if ct > rv[1]:
			rv = (val, ct)
		elif ct == rv[1] and val < rv[0]:
			rv = (val, ct)
	print(rv[0], rv[1])


def solve():
	N = int(input())
	V = [0] * 10001
	I = list(map(int, input().split()))
	for i in I:
		V[i] += 1
	Ans = 0
	for i in range(len(V)):
		if V[i] > V[Ans]:
			Ans = i
	print(Ans, V[Ans])

def main():
	t = int(input())
	for i in range(t):
		solve()
main()


lists = []
results = []
for a in range(eval(input())):
	eval(input())
	lists.append([int(x) for x in input().split()])
for element in lists:
	results = []
	for n in element:
		ns = [x[0] for x in results]
		if n in ns:
			results[ns.index(n)][1] += 1
		else:
			results.append([n, 1])
	results.sort(key=lambda x: x[0])
	results.sort(key=lambda x: x[1], reverse=True)
	print(' '.join([str(x) for x in results[0]]))


import sys
for _ in range(int(sys.stdin.readline())):
	l = int(sys.stdin.readline())
	a = sys.stdin.readline().split()
	a = list(map(int, a))
	t = set(a)
	count = []
	c = []
	if len(t) == len(a):
		print(min(a), 1)
	elif len(t) == 1:
		print(a[0], l)
	else:
		for j in t:
			c.append(j)
		c.sort()
		for i in c:
			num = a.count(i)
			count.append(num)
		times = max(count)
		index = count.index(times)
		print(c[index], times)


n = int(input())
while n:
	size = int(input())
	a = []
	a = input().split()
	i = 0
	while i < len(a):
		a[i] = int(a[i])
		i += 1
	j = max(a)
	freq = []
	freq = (j + 1) * [0]
	k = 0
	while k < len(a):
		if a[k] != 0:
			freq[a[k] - 1] += 1
			k += 1
	count = max(freq)
	key = freq.index(count) + 1
	print(key, count)
	n -= 1


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = list(map(int, str(input()).split()))
	k = set(l)
	maxi = 0
	num = 10001
	for i in k:
		c = l.count(i)
		if c > maxi:
			maxi = c
			num = i
		elif c == maxi and i < num:
			num = i
	print(num, maxi)


T = int(input())
for t in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	D = {}
	for e in A:
		D[e] = D.get(e, 0) + 1
	C = max(D.values())
	V = min([e[0] for e in [e for e in list(D.items()) if e[1] == C]])
	print(V, C)


i = input('')
i = int(i)
x = 0
ans = []
while x < i:
	a = input('')
	arr = input('')
	arr = arr.split()
	cnts = []
	y = 0
	while y < len(arr):
		temp = [0, 0]
		temp[0] = int(arr[y])
		temp[1] = arr.count(arr[y])
		cnts.append(temp)
		y = y + 1
	maxi = 10001
	maxicount = 0
	y = 0
	while y < len(cnts):
		if cnts[y][1] > maxicount:
			maxicount = cnts[y][1]
			maxi = cnts[y][0]
		elif cnts[y][1] == maxicount:
			maxicount = cnts[y][1]
			if cnts[y][0] < maxi:
				maxi = cnts[y][0]
		y = y + 1
	ans.append(str(maxi) + ' ' + str(maxicount))
	x = x + 1
x = 0
while x < len(ans):
	print(ans[x])
	x = x + 1


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	v = list(map(int, sys.stdin.readline().split()))
	v.sort()
	(xm, cm) = (v[0], 0)
	(x, c) = (v[0], 0)
	for i in v:
		if i == x:
			c += 1
		else:
			if c > cm or (c == cm and x < xm):
				(xm, cm) = (x, c)
			(x, c) = (i, 1)
	if c > cm or (c == cm and x < xm):
		(xm, cm) = (x, c)
	print(xm, cm)


import sys
result = []
n = int(sys.stdin.readline())
for i in range(0, n):
	sys.stdin.readline()
	original = [int(numero) for numero in sys.stdin.readline().strip().split()]
	l = list(set(original))
	l.sort()
	repeats = 0
	number = l[0]
	for j in l:
		c = original.count(j)
		if c > repeats:
			repeats = c
			number = j
	result.append(str(number) + ' ' + str(repeats))
sys.stdout.write('\n'.join(result))


from array import array

def solve():
	n = int(input())
	inp = list(map(int, input().split()))
	mx = max([inp.count(i) for i in inp])
	ans = min([x for x in inp if inp.count(x) == mx])
	print(str(ans) + ' ' + str(inp.count(ans)))
t = int(input())
for i in range(0, t):
	solve()


cases = int(input())
for case in range(cases):
	n = int(input())
	freq = [0] * 10001
	a = list(map(int, input().split()))
	largest = 1
	for i in range(n):
		freq[a[i]] += 1
		largest = max(largest, a[i])
	most = 0
	for num in range(largest + 1):
		if freq[num] > freq[most]:
			most = num
	print(most, freq[most])


def maxcount(lst):
	op = [0] * max(lst)
	for i in lst:
		op[i - 1] += 1
	return (op.index(max(op)) + 1, max(op))
t = int(input())
while t > 0:
	input()
	lst = [int(i) for i in input().split(' ')]
	counts = maxcount(lst)
	for i in counts:
		print(i, end=' ')
	print('')
	t -= 1


n = int(input())
for i in range(1, n + 1):
	k = int(input())
	t = [0] * 10001
	s = input().split()
	for j in range(0, k):
		l = int(s[j])
		t[l] += 1
	max = 0
	for j in t:
		if j > max:
			max = j
	for (l, j) in enumerate(t):
		if j == max:
			print(str(l) + ' ' + str(j))
			break


t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c = {}
	for elem in a:
		if elem in c:
			c[elem] += 1
		else:
			c[elem] = 1
	bestCount = 0
	best = 0
	for elem in c:
		if c[elem] > bestCount:
			bestCount = c[elem]
			best = elem
		elif c[elem] == bestCount and elem < best:
			best = elem
	print(best, bestCount)


def main():
	no_tcase = int(input())
	for i in range(no_tcase):
		countdict = {}
		no_ele = int(input())
		ls = [int(ele) for ele in input().split()]
		for ele in range(no_ele):
			if ls[ele] in countdict:
				countdict[ls[ele]] = countdict[ls[ele]] + 1
			else:
				countdict[ls[ele]] = 1
		maxk = ls[0]
		maxval = countdict[maxk]
		for key in list(countdict.keys()):
			if countdict[key] > maxval:
				maxk = key
				maxval = countdict[key]
			elif countdict[key] == maxval and maxk > key:
				maxk = key
			else:
				continue
		print(maxk, maxval)

def __starting_point():
	main()
__starting_point()


import sys
ifs = sys.stdin
ofs = sys.stdout
from itertools import repeat
from heapq import nlargest
from operator import itemgetter

class bag(dict):

	def __init__(self, data=()):
		self.update(data)

	def __missing__(self, key):
		return 0

	def update(self, other):
		if hasattr(other, 'items'):
			super(bag, self).update(other)
		else:
			for elem in other:
				self[elem] += 1

	def __setitem__(self, elem, n):
		if n <= 0:
			if elem in self:
				del self[elem]
		else:
			super(bag, self).__setitem__(elem, n)

	def itermultiple(self):
		for (elem, cnt) in self.items():
			for _ in range(cnt):
				yield elem

	def nitems(self):
		return sum(self.values())

	def most_common(self, n=None):
		if n is None:
			return sorted(iter(self.items()), key=itemgetter(1), reverse=True)
		else:
			return nlargest(n, iter(self.items()), key=itemgetter(1))

	def __repr__(self):
		return '%s(%s)' % (self.__class__.__name__, dict.__repr__(self))

	def add(self, item, n=1):
		self[item] += n

	def discard(self, item, n=1):
		self[item] -= n

def solve(A):
	C = bag(A)
	MC = C.most_common()
	(e, c) = MC.pop(0)
	c_max = c
	e_min = e
	for mc in MC:
		(e, c) = mc
		if c == c_max:
			if e < e_min:
				e_min = e
		else:
			break
	return (e_min, c_max)

def numbers_from_line(d=' '):
	return [int(s) for s in ifs.readline().strip().split(d) if len(s.strip()) > 0]
T = int(ifs.readline())
for t in range(1, T + 1):
	n = int(ifs.readline())
	A = numbers_from_line()
	(v, c) = solve(A)
	ofs.write('%d %d\n' % (v, c))
sys.exit(0)


x = int(input())
for i in range(x):
	y = int(input())
	h = {}
	k = input()
	k = k.split(' ')
	for j in range(y):
		if not h.get(k[j]):
			h[k[j]] = 1
		else:
			h[k[j]] += 1
	number = 10000
	occur = 0
	for key in list(h.keys()):
		if h[key] > occur:
			occur = h[key]
			number = key
		elif h[key] is occur:
			if int(key) < int(number):
				number = key
	print(str(number) + ' ' + str(occur))