#include<stdio.h>
int main()
{
int i, t, n;
scanf("%d", &t);
while (t--)
{
int a[10010], max = 0, ctr = 0, pos=0, k, x;
scanf("%d", &n);
for (i = 0; i < 10010; i++)
a[i] = 0;
for (i = 0; i < n; i++)
{
scanf("%d", &x);
a[x - 1]++;
if (max < x)
{
max = x;
}
}
for (i = 0; i < max; i++)
if (a[i]!=0)
{
if (ctr < a[i])
{
ctr = a[i];
pos = i;
}
if (ctr == a[i])
{
if (pos>i)
{
pos = i;
}
}
}
pos++;
printf("%d %d", pos++, ctr);
}
return 0;
}