#P6442. [COCI 2011/2012 #6] KOŠARE

[COCI 2011/2012 #6] KOŠARE

Description

In an abandoned attic, there are nn boxes, and these boxes store mm types of toys. For the ii-th box, it contains kik_i toys (different boxes may contain the same toy).

Now you need to choose some of the boxes so that, among the chosen boxes, there are all mm types of toys (that is, every toy type is included). Find the total number of ways to choose such boxes (mod 109+7\bmod\ 10^9+7).

Input Format

The first line contains two integers n,mn, m.

The next nn lines each start with an integer kik_i; then kik_i numbers describe which toys are contained in the ii-th box.

Output Format

Output one integer: the total number of valid selections (mod 109+7\bmod\ 10^9+7).

3 3
3 1 2 3
3 1 2 3
3 1 2 3
7
3 3
1 1
1 2
1 3
1
4 5
2 2 3
2 1 2
4 1 2 3 5
4 1 2 4 5
6

Hint

Constraints

  • For 50%50\% of the testdata, n100n\le 100, m15m\le 15.
  • For 70%70\% of the testdata, m15m\le 15.
  • For 100%100\% of the testdata, 1n1×1061\le n\le 1\times 10^6, 1m201\le m\le 20, 0kim0\le k_i\le m.

Notes

Translated by ChatGPT 5