Hostile Bitotia has attacked Byteotia and occupied a large part of its territory. King Byteasar of Byteotia wants to organize a resistance movement in the occupied area, so he begins by choosing the people who will form its core. These chosen people must be split into two groups:
The split has to satisfy all of the following rules:
Byteasar wants to know how many ways there are to split the chosen people into these two groups, and above all whether any valid split exists at all. Help him find this number.
The first line contains one integer n (2≤n≤5000), the number of people involved. The people are numbered from 1 to n.
Each of the next n lines describes the acquaintances of one person. The i-th of these lines begins with an integer ki (0≤ki≤n−1), the number of people that person i knows, followed by ki integers ai,1,ai,2,…,ai,ki given in increasing order (1≤ai,j≤n, ai,j=i), the numbers of those acquaintances.
Acquaintance is mutual: if person x appears among person i's acquaintances, then person i appears among person x's acquaintances.
Print one integer: the number of ways to split the chosen people into the conspirators and the support group so that all the rules above hold. If no valid split exists, print 0.

In the example above there are three valid splits. The group of conspirators can be persons 1 and 4, persons 2 and 4, or person 4 alone.