#CF2240B. AI 在这里什么也找不到 / B. AI Finds Nothing Here
AI 在这里什么也找不到 / B. AI Finds Nothing Here
B. AI Finds Nothing Here
Source: Codeforces 2240B
Contest: Codeforces Round 1105 (Div. 2)
Time limit: 1 second
Memory limit: 256 megabytes
Statement
Milkcat2009 has a matrix with rows and columns consisting of integers and . The rows are numbered from to , and the columns are numbered from to . The element in the -th row and -th column is denoted as .
Milkcat2009's AI scans every single submatrix of consisting of rows and columns. The AI considers the matrix clean if the bitwise XOR sum of elements in each such submatrix is equal to .
Formally, the matrix is valid if and only if for all and : $$ \bigoplus_{x=i}^{i+r-1} \bigoplus_{y=j}^{j+c-1} a_{x,y} = 0 $$
where denotes summation with the bitwise XOR operation.
Your task is, given various sets of integers , to count the number of clean matrices of rows and columns with respect to scanning dimensions and . Since the answer can be very large, calculate it modulo .
A submatrix of a matrix is obtained by removing some rows (from the beginning and/or end) and/or columns (from the beginning and/or end) from the original matrix.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
Each test case consists of a single line containing four integers (, ), representing the dimensions of the matrix and the dimensions of the scanning area, respectively.
Output
For each test case, output a single integer representing the answer modulo .
Note
For the first test case. The only element must satisfy . Since must be , there is only valid matrix: .
For the second test case.The condition requires the XOR sum of every submatrix to be . This implies , so for all valid . For each row, all elements must be equal. Thus, each row can be either or . With rows, there are valid matrices.
Examples
8
1 1 1 1
2 3 1 2
2 5 2 2
3 5 2 2
4 6 2 2
100 14 52 6
1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1 1
1
4
64
128
512
543661425
121099884
1