#include<iostream>
#include<math.h>
using namespace std;
//int size = 100001;
int main (){
int Test;
cin>>Test;
while(Test>0){
int n;
int max =-1;
cin>>n;
int loki[100001];
for (int i=0;i<n;i++){
cin>>loki[i];
if(loki[i]>max){
max=loki[i];
}
}
for(int i=0;i<n;i++){
if(loki[i]==max){
cout<<loki[i]<<" ";
}
}
cout<<endl;
Test--;
}
}