import java.io.*;
class counting
{
public static void main (String args[])throws IOException
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(in.readLine());
while(t–>0)
{
int n=Integer.parseInt(in.readLine());
String s=in.readLine();
int a[]=new int[n];
for(int i=0;i<n;i++)
{
a[i]=Integer.parseInt(s.split(" ")[i]);
}
int b[]=new int[100];
for(int i=0;i<100;i++)
b[i]=0;
int y=0,max=0;
for(int j=0;j<n;j++)
{
b[a[j]-0]++;
}
for(int i=0;i<=100;i++)
{
if(max<b[i])
{
max=b[i];
y=i;
}
}
System.out.println(y+" "+max);
}
}
}