atcoder#ABC289C. [ABC289C] Coverage
[ABC289C] Coverage
Score : points
Problem Statement
There are sets, called , consisting of integers between and . consists of integers .
There are ways to choose one or more sets from the sets. How many of them satisfy the following condition?
- For all integers such that , there is at least one chosen set containing .
Constraints
- $1 \leq a_{i,1} \lt a_{i,2} \lt \dots \lt a_{i,C_i} \leq N$
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the number of ways to choose sets that satisfy the conditions in the Problem Statement.
3 3
2
1 2
2
1 3
1
2
3
The sets given in the input are $S_1 = \lbrace 1, 2 \rbrace, S_2 = \lbrace 1, 3 \rbrace, S_3 = \lbrace 2 \rbrace$. The following three ways satisfy the conditions in the Problem Statement:
- choosing ;
- choosing ;
- choosing .
4 2
2
1 2
2
1 3
0
There may be no way to choose sets that satisfies the conditions in the Problem Statement.
6 6
3
2 3 6
3
2 4 6
2
3 6
3
1 5 6
3
1 3 6
2
1 4
18