Codeforces Round 366 (Div. 2)
E
Black Widow
Codeforces
未评级
原题
← D→
翻译中…

Natalia Romanova is trying to test something on the new gun S.H.I.E.L.D gave her. In order to determine the result of the test, she needs to find the number of answers to a certain equation. The equation is of form:

翻译中…

image

翻译中…

Where image represents logical OR and image represents logical exclusive OR (XOR), and $*v*_{*i*, *j*}$ are some boolean variables or their negations. Natalia calls the left side of the equation a XNF formula. Each statement in brackets is called a clause, and $*v*_{*i*, *j*}$ are called literals.

翻译中…

In the equation Natalia has, the left side is actually a 2-XNF-2 containing variables $*x*_{1}, *x*_{2}, ..., *x*_{*m*}$ and their negations. An XNF formula is 2-XNF-2 if:

翻译中…
  1. For each $1 ≤ *i* ≤ *n*$, $*k*_{*i*} ≤ 2$, i.e. the size of each clause doesn't exceed two.
  2. Each variable occurs in the formula at most two times (with negation and without negation in total). Please note that it's possible that a variable occurs twice but its negation doesn't occur in any clause (or vice versa).
翻译中…

Natalia is given a formula of $*m*$ variables, consisting of $*n*$ clauses. Please, make sure to check the samples in order to properly understand how the formula looks like.

翻译中…

Natalia is more into fight than theory, so she asked you to tell her the number of answers to this equation. More precisely, you need to find the number of ways to set $*x*_{1}, ..., *x*_{*m*}$ with $*true*$ and $*false*$ (out of total of $2^{*m*}$ ways) so that the equation is satisfied. Since this number can be extremely large, you need to print the answer modulo $10^{9} + 7$.

翻译中…

Please, note that some variable may appear twice in one clause, or not appear in the equation at all (but still, setting it to $*false*$ or $*true*$ gives different ways to set variables).

翻译中…

Input

翻译中…

The first line of input contains two integers $*n*$ and $*m*$ ($1 ≤ *n*, *m* ≤ 100 000$) — the number of clauses and the number of variables respectively.

翻译中…

The next $*n*$ lines contain the formula. The $*i*$-th of them starts with an integer $*k*_{*i*}$ — the number of literals in the $*i*$-th clause. It is followed by $*k*_{*i*}$ non-zero integers $*a*_{*i*, 1}, ..., *a*_{*i*, *k*_{*i*}}$. If $*a*_{*i*, *j*} > 0$ then $*v*_{*i*, *j*}$ is $*x*_{*a*_{*i*, *j*}}$ otherwise it's negation of $*x*_{ - *a*_{*i*, *j*}}$ ($1 ≤ *k*_{*i*} ≤ 2$, $- *m* ≤ *a*_{*i*, *j*} ≤ *m*$, $*a*_{*i*, *j*} ≠ 0$).

翻译中…

Output

翻译中…

Print the answer modulo $1 000 000 007$ ($10^{9} + 7$) in one line.

翻译中…

Note

翻译中…

The equation in the first sample is:

翻译中…

image

翻译中…

The equation in the second sample is:

翻译中…

image

翻译中…

The equation in the third sample is:

翻译中…

image

翻译中…

样例

Input #1
6 7
2 4 -2
2 6 3
2 -7 1
2 -5 1
2 3 6
2 -2 -5
Output #1
48
InputCopy OutputCopy
Input #2
8 10
1 -5
2 4 -6
2 -2 -6
2 -7 9
2 10 -1
2 3 -1
2 -8 9
2 5 8
Output #2
544
InputCopy OutputCopy
Input #3
2 3
2 1 1
2 -3 3
Output #3
4
InputCopy OutputCopy
题目信息
题号
705E
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。