H. Control
time limit per test
0.8 seconds
memory limit per test
28 megabytes
input
standard input
output
standard output

You are given a directed graph with nodes and edges. You can say that node controls node if you can reach node from node only using the edges in the graph. For each node in the graph, you must print the number of nodes that node controls.

Input

The first line contains (), the number of nodes. lines follow. Each line starts with a number , followed by numbers, representing the nodes that has an edge to. It is guaranteed that the sum of the numbers is less than . Also, there are no more than maximal subsets of nodes such that for any edge in the subset, there is a series of edges connecting with .

Output

You must print numbers on the first line, separated by a blank space, where the th number represents the number of nodes controlled by .

Example
Input
7
2 5 2
0
1 2
3 3 5 1
2 1 2
3 1 2 3
3 2 5 6
Output
3 1 2 5 3 5 6