Problems
Connected components Adjacency List
Connected components Adjacency List
Find the number of connected components in the graph given by adjacency list.
\InputFile
The first line contains the number of vertices $n~(1 \le n \le 10000)$. Then $n$ lines are given. The $i$-th line contains the description of all edges, outgoing from the $i$-th vertex. Description starts with the number of outgoing edges. Then given the vertex numbers where the edges go. All vertices are numbered from $1$ to $n$.
\OutputFile
Print the number of connected components.
\includegraphics{https://static.e-olymp.com/content/c9/c9272b27373f80b8a7d5e6c9522979c6988e5487.gif}
Input example #1
6 2 5 6 0 0 1 5 2 1 4 1 1
Output example #1
3