#include <iostream>
#include <iomanip>
#include <map>
using namespace std;
int main() {
int T;
while ( cin >> T ) {
getchar();
getchar();
for ( int i = 0; i < T ; ++i ) {
map <string, int> numSpecies;
int total = 0;
string input;
while ( getline ( cin, input ) && input != "" )
++numSpecies[input], ++total;
for ( auto it = numSpecies.begin(); it != numSpecies.end(); ++it )
cout << it->first << " " << fixed << setprecision(4) << (double) it->second / total * 100 << endl;
cout << endl;
}
}
return 0;
}