#P1167C. News Distribution

    ID: 4772 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>dfs and similardsugraphs*1400

News Distribution

No submission language available for this problem.

Description

In some social network, there are nn users communicating with each other in mm groups of friends. Let's analyze the process of distributing some news between users.

Initially, some user xx receives the news from some source. Then he or she sends the news to his or her friends (two users are friends if there is at least one group such that both of them belong to this group). Friends continue sending the news to their friends, and so on. The process ends when there is no pair of friends such that one of them knows the news, and another one doesn't know.

For each user xx you have to determine what is the number of users that will know the news if initially only user xx starts distributing it.

The first line contains two integers nn and mm (1n,m51051 \le n, m \le 5 \cdot 10^5) — the number of users and the number of groups of friends, respectively.

Then mm lines follow, each describing a group of friends. The ii-th line begins with integer kik_i (0kin0 \le k_i \le n) — the number of users in the ii-th group. Then kik_i distinct integers follow, denoting the users belonging to the ii-th group.

It is guaranteed that i=1mki5105\sum \limits_{i = 1}^{m} k_i \le 5 \cdot 10^5.

Print nn integers. The ii-th integer should be equal to the number of users that will know the news if user ii starts distributing it.

Input

The first line contains two integers nn and mm (1n,m51051 \le n, m \le 5 \cdot 10^5) — the number of users and the number of groups of friends, respectively.

Then mm lines follow, each describing a group of friends. The ii-th line begins with integer kik_i (0kin0 \le k_i \le n) — the number of users in the ii-th group. Then kik_i distinct integers follow, denoting the users belonging to the ii-th group.

It is guaranteed that i=1mki5105\sum \limits_{i = 1}^{m} k_i \le 5 \cdot 10^5.

Output

Print nn integers. The ii-th integer should be equal to the number of users that will know the news if user ii starts distributing it.

Samples

Sample Input 1

7 5
3 2 5 4
0
2 1 2
1 1
2 6 7

Sample Output 1

4 4 1 4 4 2 2