题号:NC216159
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
We call a matrix "01 Square" if and only if it's a

matrix and its elements are all

or

.
For two 01 Squares

,

, we define two operators

and

. The value of them are also 01 Square matrices and calculated below(we use

to abbreviate

and

to abbreviate

):
Now MianKing has two 01 Squares

, he wants to solve the matrix equation below:
You need to help MainKing solve this problem by calculating how many 01 Squares

satisfy this equation.
The answer may be very large, so you only need to output the answer module

.
输入描述:
The first line has one integer 
Then there are
lines and each line has
integers, the j-th integer of the i-th line denotes 
Then there are
lines and each line has
integers, the j-th integer of the i-th line denotes 
, 
输出描述:
Output the answer module
.
示例2
输入
复制
3
1 0 0
0 1 0
0 0 1
1 1 1
1 1 1
1 1 1
示例3
输入
复制
4
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 1
1 0 1 1
0 1 1 1
1 0 0 1
1 1 1 0