F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Equation of XOR

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 1019    Accepted Submission(s): 316


Problem Description
Recently, Jimmy is learning about linear algebra from Blue Mary while having the course of Boolean algebra in class offered by Prof. Z. Since Jimmy has been thoroughly bored by the boring homework assigned by two teachers, evil Jimmy plans to set a hard question to baffle them as revenge for their heavy tasks. As a result, Jimmy comes up with an idea that merging the knowledge from both the two classes and constructs a complicate problem: the XOR equation system.
Let¡¯s consider the following equations:
(a11 . x1) ^ (a12 . x2) ^ ¡­ ^ (a1m . xm) = 0
(a21 . x1) ^ (a22 . x2) ^ ¡­ ^ (a2m . xm) = 0
¡­
(an1 . x1) ^ (an2 . x2) ^ ¡­ ^ (anm . xm) = 0
which satisfies the following conditions:
1.  aij in {0,1}   for 1 ¡Ü i ¡Ü n and 1 ¡Ü j ¡Ü m;
2.  xi in Si where Si is a subset of {0,1,2,3}, 1 ¡Ü i ¡Ü m;
3.  |Si| ¡Ü 3, 1 ¡Ü i ¡Ü m;
4.  1¡Ün ¡Ü 30, 1 ¡Ü m ¡Ü 22.

In the system of equations, operation ¡° . ¡° denotes the multiplication operation while ¡° ^ ¡± is for bitwise XOR. Moreover, the bitwise XOR takes two bit patterns of equal length and performs the logical XOR operation on each pair of corresponding bits. The result in each position is 1 if the two bits are different, and 0 if they are the same.
Rather than expecting a solution of a specified equation system, Jimmy would like to ask the teachers to calculate that how many distinct solutions can satisfy a given equation system. What a confusing puzzle! Help Jimmy¡¯s teachers please!
 

Input
There are several test cases. The first line of input is a single positive integer T (<= 15) indicating the number of test cases, then T cases follow.
For each test case, the first line contains two integers N and M giving the two dimensions of the equation system respectively where N is the number of rows and M for columns. Then N lines are following, each line contains m integers. Item at line i and column j represents aij. The next m lines are descriptions of Si that the leading integer K denotes the number of elements in Si and the following K integers represent elements.
 

Output
For each test case, output one line containing a single integer which represents the answer of this case.
 

Sample Input
1 1 2 1 1 3 0 1 2 2 3 1
 

Sample Output
1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-19 15:45:33, Gzip enabled