ml3 | Musical Fight

This was the problem page during the contest. Access the current page here.
Time limit: 1s Memory limit: 16MB Input: Output:

Giorgio and Edoardo are talking about their favourite music genres, and the discussion is getting intense as they approach the trap music topic! Giorgio argues that trap lyrics are all the same, while Edoardo is a diehard fan of the genre and can’t tolerate such slander. In order to prove Giorgio wrong, he decided to measure how much his favourite trap song is original.

Thus, Edoardo collected the NN trap greatest hits, the first of which is his favourite. For each word of his favourite song, he wants to compute in how many other songs this word has already appeared, and then come back to Giorgio with the evidence collected this way, proving trap supremacy!

Input data

The first line contains the two integers NN and LL. Further NN lines follow, each describing the ii-th song through an integer MiM_i (the number of words in the lyrics) followed by MiM_i space-separated words (each composed of at most LL Latin lowercase letters a to z only).

Output data

You need to write a single line with M0M_0 integers: for each word of the first song, the number of other songs in which it appears.

Constraints and clarifications

  • 1L101 \leq L \leq 10.
  • 1N1 0001 \leq N \leq 1 \ 000.
  • 1Mi50001 \leq M_i \leq 5000 for each i=0N1i = 0 \dots N - 1.
  • Every word is comprised of at most LL Latin lowercase letters (a to z).
# Score Constraints
1 0 Examples
2 12 L=1L = 1
3 14 L3L \leq 3
4 27 Mi100M_i \leq 100 for each ii
5 26 N100N \leq 100
6 21 No additional limitations.

Example 1

stdin

4 9
11 oh sfera sk sk skuh marseille milano oh oui bang bang
7 sfera ebbasta oh come un bang oh
4 amo milano oh sfera
5 sfera ti bang bang ebbasta

stdout

2 3 0 0 0 0 1 2 0 2 2

Explanation

In the first sample case, the word sfera appears in all other songs, while oh and bang appear in other two songs. Finally, milano only appears in one other song, and the other words are novel.

Example 2

stdin

5 7
14 che vi che mi avolta che qui dale merale merale dale avolta merale che 
6 mi nisti nisti nisti mi mi 
11 mi avolta che cele mi dale avolta cele dale cele mi 
7 dale merale che che merale mi cele 
8 merale merale cele avolta che dale avolta che 

stdout

3 0 3 3 2 3 0 3 2 2 3 2 2 3

Log in or sign up to be able to send submissions!