#include<bits/stdc++.h>
using namespace std;
int compare(string X, string Y) 
{ 
    // first append Y at the end of X 
    string XY = X.append(Y); 
  
    // then append X at the end of Y 
    string YX = Y.append(X); 
  
    // Now see which of the two formed numbers is greater 
    return XY.compare(YX) > 0 ? 1: 0; 
} 
int main() {
	int t;
	cin>>t;
	while(t--){
        int n;
        cin>>n;
        int arr[100]; 
	for(int i = 0;i<n;i++){
		int b;
		cin>>b;
		arr[i]=to_string(b);
	}
	sort(arr,arr+n,compare);
	for(int i = 0;i<n;i++){
		cout<<arr[i];
	}
	cout<<endl;
	}
	return 0;
}