# F009B. The toys of the nursery P25090

Statement

html

The end of course is near! In a nursery, the educators have collected information about the toys that each girl and each boy like. To do it, the educators ask the children which is the toy they want to play with, and write down in a list the name of the boy/girl and the chosen toy.

The educators have asked you to write a program that counts the number of appearances of each pair child/toy.

Input

The input starts with a natural number n ≥ 1. Afterwards, there is a list with the n pairs of child’s name/toy. The names of the children are formed only by lowercase letters and digits.

Output

For each pair child/toy, print a line indicating how many times appears this pair. The list must be sorted by the name of the child, using the name of the toy as second criterion. Follow the format of the instances.

Observation

Some input lists can be very large. For this reason, your program must be efficient. We suggest you to use the function |sort()| to sort tuples (|struct|s).

Public test cases
• Input

```16
arnold train
bill blocks
albert doll1
ronnie ball
martha blocks
arnold doll2
arnold doll2
ronnie ball
nancy doll1
albert doll1
martha doll1
arnold doll2
martha train
arnold ball
ronnie ball
albert blocks

```

Output

```albert blocks 1
albert doll1 2
arnold ball 1
arnold doll2 3
arnold train 1
bill blocks 1
martha blocks 1
martha doll1 1
martha train 1
nancy doll1 1
ronnie ball 3
```
• Input

```13
nancy book
nancy train
arnold book
arnold ball
arnold train
arnold train
arnold train
bill book
eythan tiger
carla ball
carla ball
bob doll
robert train
```

Output

```arnold ball 1
arnold book 1
arnold train 3
bill book 1
bob doll 1
carla ball 2
eythan tiger 1
nancy book 1
nancy train 1
robert train 1
```
• Input

```3
biel train
biel train
biel train
```

Output

```biel train 3
```
• Information
Author
Professorat de P1
Language
English
Translator
Carlos Molina
Original language
Catalan
Other languages
Catalan
Official solutions
C++
User solutions
C++