#include
#include
using namespace std;
int main()
{
int t;
cin >> t;
while (t > 0){
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++){
cin >> arr[i];
}
for (int i = 0; i < n; i++){
for (int j = i + 1; j < n; j++){
if (arr[i] == 0){
swap(arr[i],arr[n-1]);
}
int digitx = 0, digity = 0;
int temp = arr[i];
while (temp > 0){
digitx++;
temp /= 10;
}
temp = arr[j];
while (temp > 0){
digity++;
temp /= 10;
}
int xy = (arr[i] * pow(10, digity)) + arr[j];
int yx = (arr[j] * pow(10, digitx)) + arr[i];
if (yx > xy){
swap(arr[i], arr[j]);
}
}
}
for (int i = 0; i < n; i++){
cout << arr[i];
}
cout << endl;
t–;
}
return 0;
}