#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <assert.h>

using namespace std;


int r(int max)
{
	int r;
	do
	{
		r = rand()%max;
	}
	while(r < 1);
	return r;
}

void generate_color(int n)
{
	for(int i=0; i<n; i++)
	{
		int c;
		c = r(100);
				
		cout << c;
		if (i!= n-1) cout << " ";			
	}
	cout << endl;
}

void generate_tests(int test)
{
	int n;
	
	cout << 1 << endl;
	cout << 1 << endl;

	for(int t=0; t<test-5; t++)
	{
		int n;
		n = r(10000);		
	
		cout << n << endl;
		generate_color(n);			
	}

	n = 10000;
	cout << n << endl;
	generate_color(n);

	n = 10000;
	cout << n << endl;
	generate_color(n);

	n = 10000;
	cout << n << endl;
	for(int i=0; i<n; i++)
	{
		cout << 100;
		if (i<n) cout << " ";
	}
	cout << endl;

	n = 10000;
	cout << n << endl;
	for(int i=0; i<n; i++)
	{
		cout << 1;
		if (i<n) cout << " ";
	}
	cout << endl;
}



int main()
{
	freopen("apparel.in", "r", stdin);
	//freopen("apparel.out", "w", stdout);
	
	/*generate_tests(28);
	return 0;*/

	int test;
	cin >> test;
	for(int t=0; t<test; t++)
	{
		int n;
		cin >> n;

		assert(1 <= n && n <=10000);
		
		int color;
		int count[128]={0};
		
		for(int i=0; i<n; i++)
		{
			cin >> color;
			assert(1 <= color && color <= 100);
			count[color]++;					
		}		

		int imax = 0;
		for(int i=1; i<=100; i++)
		{
			if (count[imax] < count[i]) imax = i;
		}

		bool many = false;
		for(int i=1; i<=100; i++)
		{
			if (count[i] == count[imax] && imax != i) many = true;
		}


		cout << (many ? 0 : imax) << endl;
	}

	return 0;
}

