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.

----- Sample Input 1 ------ 
2
5
1 2 3 2 5
6
1 2 2 1 1 2
----- Sample Output 1 ------ 
2 2
1 3
----- explanation 1 ------ 
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.

Difficulty: EASY

Solutions:
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	k = [0] * 10001
	for i in range(n):
		k[l[i]] += 1
	c = max(k)
	index = k.index(c)
	print(index, c)


t = int(input())
for _ in range(t):
	n = int(input())
	integers = list(map(int, input().split()))
	array = [0] * 10001
	for i in range(n):
		array[integers[i]] += 1
	count = max(array)
	index = array.index(count)
	print(index, count)


from collections import Counter
for t in range(int(input())):
	n = int(input())
	a = Counter(map(int, input().split(' ')))
	a1 = a.items()
	v = max(a.values())
	l = []
	for (key, value) in a1:
		if value == v:
			l.append(key)
	print(min(l), v)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = Counter(a)
	dict_items = x.items()
	m = max(x.values())
	l = []
	for (key, value) in dict_items:
		if value == m:
			l.append(key)
	print(min(l), m)


T = int(input())
l = []
for i in range(T):
	N = int(input())
	ele = input()
	l = list(map(int, ele.split()))
	counter = 0
	l = sorted(l)
	num = l[0]
	for i in l:
		curr_frequency = l.count(i)
		if curr_frequency > counter:
			counter = curr_frequency
			num = i
	print(f'{num} {counter}')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = set(a)
	b = list(b)
	n = 0
	maxi = 0
	b.sort()
	for i in b:
		if a.count(i) > maxi:
			n = i
			maxi = a.count(i)
	print(f'{n} {maxi}')


T = int(input())
for t in range(T):
	a = int(input())
	b = list(map(int, input().split()))
	b.sort()
	c = 0
	count_old = 0
	for i in range(a):
		count_new = b.count(b[i])
		if count_new > count_old:
			count_old = count_new
			c = b[i]
	print(c, count_old)


T = int(input())
for i in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	c = 0
	val = 0
	for j in range(n):
		count = a.count(a[j])
		if count > c:
			c = count
			val = a[j]
		elif count == c:
			if val > a[j]:
				val = a[j]
	print(val, c)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = Counter(input().split())
	two = ((int(x[0]), x[1]) for x in a.most_common())
	print(*sorted(sorted(two, key=lambda x: x[0]), key=lambda x: x[1], reverse=True)[0])


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	b = {}
	count = 0
	for i in a:
		if i in b:
			b[i] += 1
		else:
			b[i] = 1
	for i in b:
		if b[i] > count:
			count = b[i]
			index = i
	print(index, count)


T = int(input())
N = s = None
val = maxc = count = 0
for i in range(T):
	N = int(input())
	s = input() + ' '
	A = []
	k = ''
	for j in range(len(s)):
		if s[j] != ' ':
			k = k + s[j]
		else:
			A.append(int(k))
			k = ''
	temp = 0
	for i in range(len(A)):
		for j in range(i, len(A), 1):
			if A[i] == 0:
				break
			elif A[j] == A[i]:
				if j == i:
					temp = A[i]
				else:
					A[j] = 0
				count += 1
		if count == maxc:
			if val > temp:
				val = temp
		elif count > maxc:
			maxc = count
			val = temp
		count = 0
		temp = 0
	print(val, maxc)
	val = maxc = 0


qt = int(input())
for ios in range(qt):
	nn = int(input())
	a = list(map(int, input().split()))
	num = []
	(w, s) = (0, 0)
	for i in a:
		if i not in num:
			num.append(i)
			q = a.count(i)
			if s < q:
				s = q
				w = i
			if s == q:
				if w < i:
					pass
				elif w > i:
					w = i
					s = q
	print(w, s)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	num = []
	(nu, s) = (0, 0)
	for i in a:
		if i not in num:
			num.append(i)
			q = a.count(i)
			if s < q:
				s = q
				nu = i
			if s == q:
				if nu < i:
					pass
				elif nu > i:
					nu = i
					s = q
	print(nu, s)


T = int(input())
for i in range(T):
	N = int(input())
	l = list(map(int, input().split()))
	S = set(l)
	S = list(S)
	c = 0
	a = 0
	S.sort()
	for i in S:
		if l.count(i) > c:
			c = l.count(i)
			a = i
	print(a, c)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	s = list(s)
	m = 0
	a = 0
	s.sort()
	for i in s:
		if l.count(i) > m:
			m = l.count(i)
			a = i
	print(a, m)


def count_max(arr):
	dict = {}
	for i in arr:
		if i not in dict.keys():
			dict.update({i: 1})
		else:
			dict[i] += 1
	m = max(dict.values())
	c = [k for (k, v) in dict.items() if v == m]
	for (k, v) in dict.items():
		if k == min(c):
			val = k
	print(min(c), dict[val])
	return
test = int(input())
for i in range(test):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	count_max(arr)


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	b = list(set(li))
	(v, c) = (0, 0)
	b.sort()
	for j in b:
		if li.count(j) > v:
			c = j
			v = li.count(j)
	print(f'{c} {v}')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mxcnt = 0
	mx = 0
	for i in range(n):
		if arr.count(arr[i]) > mxcnt:
			mxcnt = arr.count(arr[i])
			mx = arr[i]
		elif arr.count(arr[i]) == mxcnt:
			if mx > arr[i]:
				mx = arr[i]
	print(mx, mxcnt)


t = int(input())
for tc in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	m = -1000000
	b = 0
	for j in a:
		if m < a.count(j):
			m = a.count(j)
			b = j
	print(b, m)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = -1000000
	a = 0
	for i in l:
		if m < l.count(i):
			m = l.count(i)
			a = i
	print(a, m)


for _ in range(int(input())):
	x = int(input())
	y = list(map(int, input().split()))
	z = list(set(y))
	z.sort()
	max = 0
	count = 0
	d = {}
	for i in z:
		if y.count(i) > count:
			max = i
			count = y.count(i)
	print(f'{max} {count}')


from collections import Counter
t = int(input(''))
for i in range(0, t):
	n = int(input(''))
	s = list(map(int, input().split(' ')))
	s = sorted(s, key=round)
	count = Counter(s)
	max_count = max(count.most_common(), key=lambda x: x[1])
	m = list(max_count)
	print(m[0], m[1], sep=' ')


h = int(input())
for i in range(h):
	N = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = max(l, key=l.count)
	print(m, l.count(m))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	c = 0
	m = -1000000
	for i in l:
		if m < l.count(i):
			m = l.count(i)
			c = i
	print(c, m)


t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split(' ')))
	(x, c) = (0, 0)
	v = 0
	for i in a:
		x = a.count(i)
		if x == c:
			if i < v:
				v = i
		elif x > c:
			(v, c) = (i, x)
	print(v, c)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	dic = {}
	for i in range(n):
		if l[i] not in dic:
			dic[l[i]] = 1
		else:
			dic[l[i]] += 1
	vals = list(dic.values())
	ma = max(vals)
	dic2 = {}
	for (i, j) in enumerate(dic):
		if dic[j] == ma:
			dic2[j] = ma
	print(min(dic2.keys()), max(dic2.values()))


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))[:n]
	D = sorted(list(set(arr)))
	cnt = 0
	a = 0
	for i in D:
		if arr.count(i) > cnt:
			cnt = arr.count(i)
			a = i
	print(a, cnt)
	t -= 1


from collections import Counter
for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	c = Counter(arr)
	key_max = max(c, key=c.get)
	print(key_max, c[key_max])


t = input()
for c in range(0, int(t)):
	n = int(input())
	l = list(map(int, input().split()))
	c = None
	for i in range(0, n):
		if c == None or l.count(l[i]) > c:
			c = l.count(l[i])
	j = 0
	l1 = []
	while j < n:
		if l.count(l[j]) == c:
			l1.append(l[j])
		j += 1
	l1.sort()
	print(l1[0], c)


T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	freq = {}
	for i in A:
		if i in freq:
			freq[i] += 1
		else:
			freq[i] = 1
	(k, v) = (0, 0)
	for (x, y) in freq.items():
		if y > v:
			k = x
			v = y
		if y == v and k > x:
			k = x
	print(k, v)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	d = dict()
	for i in a:
		d[i] = d.get(i, 0) + 1
	(m, n) = (0, 0)
	for (x, y) in d.items():
		if y > n:
			m = x
			n = y
		if y == n and m > x:
			m = x
	print(m, n)


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	v = 0
	c = 0
	for i in set(a):
		t = a.count(i)
		if t > c:
			v = i
			c = t
		elif t == c:
			if i < v:
				v = i
	print(v, c)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	(m, k, v) = (0, 0, 0)
	for x in s:
		if l.count(x) > v:
			k = x
			v = l.count(x)
		elif l.count(x) == v:
			if x < k:
				k = x
	print(k, v)


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	l = []
	for num in a:
		if num not in l:
			l.append(num)
	d = {}
	for i in range(len(l)):
		d[l[i]] = a.count(l[i])
	val = list(d.values())
	keys = list(d.keys())
	m = max(val)
	print(keys[val.index(m)], m)


for i in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	m = 0
	d = []
	for j in a:
		if j not in d:
			if a.count(j) > m:
				m = a.count(j)
				x = j
				d.append(j)
			elif a.count(j) == m:
				x = min(x, j)
	print(x, m)


from statistics import mode
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	print(mode(a), a.count(mode(a)))


from collections import Counter
for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	B = Counter(A)
	(num, count) = (100000, 0)
	for b in B:
		if B[b] == count:
			if num > b:
				num = b
		elif B[b] > count:
			count = B[b]
			num = b
	print(num, count)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		if i not in d:
			d[i] = 1
		else:
			d[i] = d[i] + 1
	(e, max) = (0, 0)
	for i in d.keys():
		if d[i] > max:
			max = d[i]
			e = i
	for i in d.keys():
		if d[i] == max:
			if i != e:
				if i < e:
					e = i
	print(e, max)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	l = []
	(v, c) = (0, 0)
	for i in range(len(a)):
		d[a[i]] = 0
	for j in range(len(a)):
		d[a[j]] += 1
	for key in d:
		if c < d[key]:
			c = d[key]
	for key in d:
		if d[key] == c:
			l.append(key)
	v = min(l)
	print(v, c)


t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = 0
	c = 0
	d = list(set(a))
	d.sort()
	for i in d:
		if a.count(i) > b:
			b = a.count(i)
			c = i
	print(c, b)


for j in range(int(input())):
	l = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	i = e = c = 0
	while i < len(lst):
		cnt = lst.count(lst[i])
		if cnt > c:
			c = cnt
			e = lst[i]
		i = cnt + i
	print(e, c)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))[:n]
	D = dict()
	for i in arr:
		D[i] = D.get(i, 0) + 1
	item = sorted(list(D.items()))
	mx = max(D.values())
	for (key, value) in item:
		if value == mx:
			print(key, value)
			break


for _ in range(int(input(), 10)):
	n = int(input(), 10)
	l = list(map(int, input().split()))[:n]
	maxx = l[0]
	cnt = l.count(l[0])
	for i in l:
		x = l.count(i)
		if x == cnt:
			if i < maxx:
				maxx = i
		elif x > cnt:
			cnt = x
			maxx = i
		else:
			pass
	print(maxx, cnt)


t = int(input())
for i in range(t):
	n = int(input())
	ar = map(int, input().split(' '))
	counting = dict()
	for ele in ar:
		if ele in counting.keys():
			temp = counting[ele]
			counting[ele] = temp + 1
		else:
			counting[ele] = 1
	max = 0
	for key in counting:
		if counting[key] > max:
			max = counting[key]
		else:
			continue
	value = list()
	count = 0
	for key in counting:
		if counting[key] == max:
			value.append(key)
			count += 1
	print(min(value), max)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	c = 0
	v = max(a)
	for j in a:
		C = a.count(j)
		if C > c:
			c = C
			v = j
		if C == c:
			if j < v:
				v = j
	print(str(v) + ' ' + str(c))


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split(' ')))
	d = {}
	for i in set(a):
		d[i] = a.count(i)
	x = max(d.values())
	l = []
	for i in d:
		if d[i] == x:
			l.append(i)
	print(min(l), x)
	t = t - 1


T = int(input())
for t in range(T):
	N = int(input())
	A = sorted(list((int(i) for i in input().split())))
	nums = sorted(set(A))
	count = {}
	for i in nums:
		count[i] = A.count(i)
	maxC = max(count.values())
	A1 = []
	for i in count:
		if count[i] == maxC:
			A1.append(i)
	print(min(A1), maxC)


for i in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in set(l):
		d[i] = l.count(i)
	x = max(d.values())
	l1 = []
	for i in d:
		if d[i] == x:
			l1.append(i)
	print(min(l1), x)


from collections import Counter
t = int(input())
while t:
	n = int(input())
	k = list(map(int, input().split()))
	c = Counter(k)
	l = 0
	s = []
	for (i, j) in c.items():
		l = max(j, l)
	for (i, j) in c.items():
		if j == l:
			s.append(i)
	print(min(s), l)
	t -= 1


from collections import Counter
for i in range(int(input())):
	n = int(input())
	l = Counter(list(map(int, input().strip().split(' '))))
	l1 = []
	f = max(l.values())
	for i in l:
		if l[i] == f:
			l1.append(i)
	print(min(l1), f)


t = int(input())
while t != 0:
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	k = []
	for i in arr:
		if i not in k:
			k.append(i)
	l = []
	for i in k:
		l.append(arr.count(i))
	m = l.index(max(l))
	print(k[m], l[m])
	t -= 1


t = int(input())
for ni in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	s = list(set(l))
	x = list()
	for i in s:
		x.append(l.count(i))
	x2 = list()
	m = max(x)
	for i in s:
		if l.count(i) == m:
			x2.append(i)
	print(min(x2), m)


from collections import Counter
for tc in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	x = [k for (k, v) in c.items() if v == max(c.values())]
	print(min(x), a.count(min(x)))


t = int(input())
while t != 0:
	n = int(input())
	l = list(map(int, input().split()))
	v = m = 0
	for i in range(0, n):
		if l.index(l[i]) == i:
			c = l.count(l[i])
			if c > m:
				v = l[i]
				m = c
			elif c == m:
				v = min(v, l[i])
	print(v, l.count(v))
	t -= 1


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = Counter(l)
	x = max(d.values())
	a = [k for (k, v) in d.items() if x == v]
	print(min(a), l.count(min(a)))


for i in range(int(input())):
	n = int(input())
	d = {}
	l = list(map(int, input().split()))
	for x in l:
		d[x] = d.get(x, 0) + 1
	max1 = 0
	ele = float('+INF')
	for x in d:
		c = d.get(x)
		if c >= max1:
			max1 = c
			if ele > x or d.get(ele) < max1:
				ele = x
	print(ele, max1)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	max = 0
	for i in arr:
		temp = arr.count(i)
		if temp > max:
			max = temp
			var = i
		elif temp == max:
			if var > i:
				var = i
	print(var, max)


for _ in range(int(input())):
	n = int(input())
	m = sorted([int(i) for i in input().split()])
	x = max([m.count(i) for i in set(m)])
	for i in m:
		if m.count(i) == x:
			print(i, x)
			break


for _ in range(int(input())):
	n = int(input())
	num_list = list(map(int, input().split()))
	val = -99999
	count = -99999
	for i in set(num_list):
		temp = num_list.count(i)
		if temp > count:
			count = temp
			val = i
		elif temp == count and i < val:
			count = temp
			val = i
	print(val, count)


for __ in range(int(input())):
	mov = int(input())
	L = [int(i) for i in input().split(' ')]
	d = {i: L.count(i) for i in L}
	Li = []
	Lr = []
	for i in d.values():
		Li.append(i)
	for (i, j) in d.items():
		if j == max(Li):
			Lr.append(i)
	Lr.sort()
	print(Lr[0], max(Li))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		d[i] = d.get(i, 0) + 1
	d = dict(sorted(d.items(), key=lambda x: x[1], reverse=True))
	for i in d:
		max = d[i]
		break
	d1 = {}
	for i in d:
		if d[i] == max:
			d1[i] = d[i]
	d1 = dict(sorted(d1.items(), key=lambda x: x[0]))
	for i in d1:
		print(i, d1[i])
		break


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	temp = 0
	arr = []
	no = 0
	for i in sorted(a):
		if i not in arr:
			arr.append(i)
	for i in range(len(arr)):
		if a.count(arr[i]) > temp:
			temp = a.count(arr[i])
			no = arr[i]
	print(no, temp)


t = int(input())
for dummy in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	a.append(10001)
	best_v = a[0]
	curr_c = 1
	best_c = 0
	for i in range(1, len(a)):
		if a[i] == a[i - 1]:
			curr_c += 1
		else:
			if curr_c > best_c:
				best_c = curr_c
				best_v = a[i - 1]
			curr_c = 1
	print(best_v, best_c)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	freq = {}
	for item in a:
		if item in freq:
			freq[item] += 1
		else:
			freq[item] = 1
	max_value = max(freq.values())
	min_key = 0
	for key in freq:
		if freq[key] == max_value:
			min_key = key
			break
	print(min_key, max_value, sep=' ')