#include<iostream>
#include<vector>
#include<random>
#include<algorithm>
using namespace std;
int main()
{
int n; cin >> n;
while (n--)
{
int m; cin >> m;
int* a = new int[m];
for (int i = 0; i < m; i++)
{
cin >> a[i];
/*random_device d; 随机测评
a[i]=d() % 20;*/
}
vector <int>d;
sort(a, a +m);
int c = 0;
for (int i = 0; i < m; i++)
{
if (a[i] != a[i + 1])
{
c++;
d.push_back(a[i]);
}
}
int e = 0;
int* b = new int[c] {0};
for (int i = 0; i < c; i++)
{
for (int j = 0; j < m; j++)
{
if (d[i] == a[j])
{
b[i]++;
}
}
}
//for (int i = 0; i < c; i++)
//{
// cout << d[i] << " " << b[i]<<endl;随机测评
//}
int max = 0;
for (int i = 0; i < c; i++)
{
if (max < b[i]) { max = b[i]; }
}
bool f = false;
for (int i = 0; i < c; i++)
{
if (b[i] == max)
{
if (!f)
{
cout << d[i];
f = true;
}
else
{
cout << " " <<d[i];
}
}
}cout << endl;
}
return 0;
}