import java.util.*;
public class main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int lines = sc.nextInt();
sc.nextLine();
String[] datas = new String[lines];
for(int i = 0; i < lines; i++)
{
String[] str = sc.nextLine().split(" ");
datas[i] = str[0];
}
Arrays.sort(datas);
for(int i = 0; i < lines; i++)
{
String search = datas[i];
int count = 0;
for(int j = i; j < lines; j++)
{
if(datas[j].equals(search))
{
count ++;
i = j;
}
else
break;
}
System.out.println(String.format("%s %d", search, count));
}
}
};
留言
張貼留言