#include<iostream>
#include<math.h>
using namespace std;
int size = 1000001;
int main (){
int Test;
cin>>Test;
while(Test>0){
int n;
int max =-1;
cin>>n;
int loki[size];
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]<<" ";
}
}
Test--;
}
}