#include <bits/stdc++.h>
using namespace std;
#define ll long long int
void solve()
{
int n,in,in1;
cin >> n;
string ar[n],br[n],str,cr[n],dr[n];
for(int i=0;i<n;i++)
cin >> ar[i];
for(int i=0;i<n;i++)
{
in=ar[i].find_last_of(’/’);
br[i]=ar[i].substr(in+1,4);
}
for(int i=0;i<n;i++)
{
in=ar[i].find_first_of(’/’);
in1=ar[i].find_last_of(’/’);
cr[i]=ar[i].substr(in+1,in1-in-1);
}
for(int i=0;i<n;i++)
{
in=ar[i].find_first_of(’/’);
dr[i]=ar[i].substr(0,in);
}
for(int i=0;i<(n-1);i++)
{
for(int j=i+1;j<n;j++)
{
if(br[i]>br[j])
swap(ar[i],ar[j]);
else if(br[i]==br[j] && cr[i]>cr[j])
swap(ar[i],ar[i+1]);
else if(br[i]==br[j] && cr[i]==cr[j] && dr[i]>dr[j])
swap(ar[i],ar[i+1]);
}
}
for(int i=0;i<n;i++)
{
cout << ar[i] << “\n”;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
/ll tc;
cin >> tc;
while(tc–)/
solve();
}