#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t–){
int n,count=0,pcount=0,u;
cin>>n;
int a[105],b[105];
for(int i=0;i<n;i++){
cin>>a[i];
b[i] = a[i];
}
int max=INT_MIN;
for(int i=0;i<n;i++){
if(a[i]>max){
max=a[i];
}
}
while(max!=0){
max = max/10;
count++;
}
for(int i=0;i<n;i++){
int l = b[i];
while(l != 0){
l = l/10;
pcount++;
}
b[i] = b[i]* pow(10,count-pcount);
pcount = 0;
}
for(int i=0;i<n;i++){
for(int i=0;i<n;i++){
if(b[i]>max){
max=b[i];
u=i;
}
}
cout<<a[u];
b[u] = 0;
max=0;
}
cout<<endl;
}
return 0;
}