Олимпиадный тренинг

Задача 37873. stitch counting words


Задача

Темы: Словари
Cheerful alien Stitch is trying to settle down on our planet and learn English. So far, he can't say much, but he can already distinguish one word from another, although he may not understand them. Now Stitch is observing Leela, and for each word he hears, he says how many times it has already been said by Leela before. When Lilo gets tired of listening to Stitch mumbling, she calls him by his first name and Stitch stops. Jumba Jookiba, who became friends with Lilo and Nani, decided to test Stitch to see if he was keeping the score right. Help write a program for this.

Explanation
A word is a sequence of consecutive non-blank characters, words separated by one or more spaces or end-of-line characters. 

Input
The program receives text as input. The sign of the end of the text is the word STITCH, which is located in the last line, there are no other words in the last line. 

Imprint 
For each word encountered in the text, display how many times it has occurred before. The word STITCH is not included in the text.

 

Examples
# Input Output
1 one two one tho three
STITCH
0 0 1 0 0
2 a b a c a b a d a b a c a b a
STITCH
0 0 1 0 2 1 3 0 4 2 5 1 6 3 7