#P2088. Matrix Equation

Matrix Equation

题目描述

点击这里查看pdf

We call a matrix "01 Square" if and only if it's a N imesNN\ imes N matrix and its elements are all 00 or 11.

For two 01 Squares XX,YY, we define two operators X imesYX\ imes Y and XodotYX\\odot Y. The value of them are also 01 Square matrices and calculated below(we use ZZ to abbreviate X imesYX\ imes Y and DD to abbreviate XodotYX\\odot Y):

Now MianKing has two 01 Squares A,BA,B, he wants to solve the matrix equation below:

A imesC=BodotCA\ imes C=B\\odot C

You need to help MainKing solve this problem by calculating how many 01 Squares CC satisfy this equation.

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

输入格式

The first line has one integer NN

Then there are NN lines and each line has NN integers, the j-th integer of the i-th line denotes Ai,jA_{i,j}

Then there are NN lines and each line has NN integers, the j-th integer of the i-th line denotes Bi,jB_{i,j}

1leqNleq2001\\leq N\\leq 200 Ai,jin0,1A_{i,j} \\in \\{0,1\\}

Bi,jin0,1B_{i,j} \\in \\{0,1\\}

输出格式

Output the answer module 998244353998244353.

样例

2 
0 1 
1 1 
1 0 
0 1 

2 

3 
1 0 0 
0 1 0 
0 0 1 
1 1 1 
1 1 1 
1 1 1 

512 

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 

8 

提示

Form 2020ICPC济南赛站