#include <stdio.h>
int main (void){
	int i,testpass,test,element,loop=1;
	int max[101][2],a[10001]={};
	scanf(" %d" ,&testpass);
	while(loop<=testpass)
	{
		max[loop][2]=0;
		scanf(" %d",&test);
		for(;test>0;test--)
		{
			scanf(" %d",&element);
			a[element]++;
		}
		for(i=1;i<=10000;i++)
		{
			if (a[i]>max[loop][2])
			{
				i=max[loop][1];
				a[i]=max[loop][2];
			}
			a[i]=0;
		}
		
		
		loop++;
	}
	for(i=1;i<=testpass;i++)
	printf("\n%d %d",max[i][1],max[i][2] ) ;
return 0;
}