A Codetikki classroom has n students whose friendships can be represented as an adjacency list. Each student belongs to a friend group defined as the transitive closure of their friendship relations. Given a friendship adjacency list, determine the number of friend groups. Input: first line n (number of students), then n lines each starting with student id and number of friends, followed by friend ids.
Example 1:
Example 2:
Constraints:
1 <= n <= 10^5 Students labeled 0 to n-1
Tags:
