CF704C.Black Widow

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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:

Where represents logical OR and represents logical exclusive OR (XOR), and vi,jv_{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 vi,jv_{i,j} are called literals.

In the equation Natalia has, the left side is actually a 2-XNF-2 containing variables x1,x2,...,xmx_{1},x_{2},...,x_{m} and their negations. An XNF formula is 2-XNF-2 if:

  1. For each 1<=i<=n1<=i<=n , ki<=2k_{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 mm variables, consisting of nn 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 x1,...,xmx_{1},...,x_{m} with truetrue and falsefalse (out of total of 2m2^{m} ways) so that the equation is satisfied. Since this number can be extremely large, you need to print the answer modulo 109+710^{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 falsefalse or truetrue gives different ways to set variables).

输入格式

The first line of input contains two integers nn and mm ( 1<=n,m<=1000001<=n,m<=100000 ) — the number of clauses and the number of variables respectively.

The next nn lines contain the formula. The ii -th of them starts with an integer kik_{i} — the number of literals in the ii -th clause. It is followed by kik_{i} non-zero integers ai,1,...,ai,kia_{i,1},...,a_{i,ki} . If a_{i,j}>0 then vi,jv_{i,j} is xai,jx_{ai,j} otherwise it's negation of xai,jx_{-ai,j} ( 1<=ki<=21<=k_{i}<=2 , m<=ai,j<=m-m<=a_{i,j}<=m , ai,j0a_{i,j}≠0 ).

输出格式

Print the answer modulo 10000000071000000007 ( 109+710^{9}+7 ) in one line.

输入输出样例

  • 输入#1

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

    输出#1

    48
    
  • 输入#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
    

    输出#2

    544
    
  • 输入#3

    2 3
    2 1 1
    2 -3 3
    

    输出#3

    4
    

说明/提示

The equation in the first sample is:

The equation in the second sample is:

The equation in the third sample is:

首页