#P12451. [INOI Team Selection 2021] Labelless Graph

[INOI Team Selection 2021] Labelless Graph

Description

Someday Shayan had a graph with nn vertices, vertices were labeled by numbers 1 to nn, but it has got stolen from him.

Thieves have sent him nn pictures of the graph, in each picture exactly one of the vertices is removed, and labels of other vertices are re-indexed from 1 to n1n-1 (each vertex will being removed in exactly one of the graphs).

The thieves have told him if he can tell the size of connected components of the graph, They will give the graph back to him, but sadly Shayan does not remember the answer to this question, so he asked you to help him find the answer.

Input Format

First line contains the number nn, number of vertices of the graph.

The following lines are the descriptions of the nn pictures. The ii-th graph starts with number mim_i, the number of edges in the graph without a specific vertex. The vertices are randomly shuffled and are indexed between 1 to n1n-1. The next mim_i lines contain the description of the edges.

It is guaranteed that the input is not self contradictory.

Output Format

In the first line of output print the number of connected components of the graph. In the next line, print the sizes of the components in the non-decreasing order.

3
1
1 2
1
1 2
1
1 2
1
3
5
2
1 2
3 1
1
1 2
2
2 3
1 4
2
2 4
3 4
2
1 2
3 4
2
2 3

Hint

Sample Explanation 2

In the second sample, the original graph has two compenents, one of them is a single edge, and the other is a P3P_3.

Constraints

  • 1n3001 \leq n \leq 300
  • n2n \neq 2
  • 0mi(n12)0 \leq m_i \leq \binom{n-1}{2}
  • 1vi,uin11 \leq v_i, u_i \leq n - 1

Subtasks

subtask score limits
1 100 No extra limits