Memory limit: 128 MB
Hostile Bitotia launched a sneak attack on Byteotia and occupied a significant part of its territory. The King of Byteotia, Byteasar, intends to organise resistance movement in the occupied area. Byteasar naturally started with selecting the people who will form the skeleton of the movement. They are to be partitioned into two groups: the conspirators who will operate directly in the occupied territory, and the support group that will operate inside free Byteotia.
There is however one issue - the partition has to satisfy the following conditions:
- Every pair of people from the support group have to know each other - this will make the whole group cooperative and efficient.
- The conspirators must not know each other.
- None of the groups may be empty, i.e., there has to be at least one conspirator and at least one person in the support group.
The first line of the standard input holds one integer (), denoting the number of people engaged in forming the resistance movement. These people are numbered from 1 to (for the sake of conspiracy!). The lines that follow describe who knows who in the group. The -th of these lines describes the acquaintances of the person with a sequence of integers separated by single spaces. The first of those numbers, (), denotes the number of acquaintances of the person . Next in the line there are integers - the numbers of 's acquaintances. The numbers are given in increasing order and satisfy , . You may assume that if occurs in the sequence (i.e., among 's acquaintances), then also occurs in the sequence (i.e., among 's acquaintances).
In the first and only line of the standard output your program should print out one integer: the number of ways to partition selected people into the conspirators and the support group. If there is no partition satisfying aforementioned conditions, then 0 is obviously the right answer.
For the input data:
4 2 2 3 2 1 3 3 1 2 4 1 3
the correct result is:
Explanation of the example: There are three ways of partitioning these people into the groups. The group of conspirators can be formed by either those numbered and , those numbered and , or the one numbered alone.
Task author: Jakub Onufry Wojtaszczyk.<Submit a solution> [0/100]