#include<iostream>
#include<cstring>#include<algorithm>using namespace std;typedef struct char_c{ char ch[6];}char_c;int fun(char_c a,char_c b){ int i; for(i=0;i<5;i++) { if(a.ch[i]>b.ch[i]){return 1;break;} if(a.ch[i]<b.ch[i]) {return 0;break;} }}int main(){ int n; const int N=1001; char_c ch1[N]; cin>>n; while(n--) { int m; cin>>m; int i; for( i = 0; i < m; i++ ) cin>>ch1[i].ch; sort(ch1,ch1+m,fun); // for( i = 0; i < m; i++ ) cout<<ch1[m-1].ch<<endl; } return 0;}