A list of names is taken as input, in which a particular name can occur multiple times. You need to arrange these names as they will appear in the dictionary and also print the number of times the arranged names appear in the list taken as input.

Input:

The first line of input contains an integer, t, which denotes the number of names that will follow. 

Then, t lines follow, each containing a name, in the form of a character string S.

Output:

The output contains the names as they would appear in the dictionary, followed by the frequency of that name in the list. 

Constraints:

1 ≤ t ≤ 100000
1 ≤ |S| ≤30
S contains only lower case characters.

SAMPLE INPUT
3
ritesh
sahil
ritesh

SAMPLE OUTPUT
ritesh 2
sahil 1

Explanation

Test Case #1:

As the name starts from 'r' comes first then 's' in dictionary and in this case the 'ritesh' name is given 2 times and 'sahil' is given only once so their frequency is coming and remove the duplicate rows.
n = int(raw_input())
name = []
for i in range(n):
    name.append(raw_input())
name.sort()
c = 1
i = 0
while i < n:

    pos = i+1
    while i < n and pos < n and name[i] == name[pos]:
        c+=1
        pos+=1
    print name[i] , c
    i = pos
    c = 1