Hardwood species
T=input()
space=input()
for t in range(int(T)):
if t>0:
print()
arr=[]
c=0
while 1:
try:
a=input()
if a!='':
arr.append(a)
c+=1
else:
break
except:
break
dic={}
for i in arr:
if i not in dic:
dic[i]=1
else:
dic[i]+=1
ans=sorted(dic.items(),key=lambda x:x[1],reverse=1)
ans=sorted(ans,key=lambda x:x[0])
for x,y in ans:
print('{} {:.4f}'.format(x,y/c*100))