luogu#P5159. WD与矩阵

WD与矩阵

Background

WD spends all day immersed in matrices and cannot get out of it.

Problem Description

WD likes matrices very much, especially 01 matrices.

One day, CX gave WD a huge nn-row, mm-column 01 matrix. WD found that the XOR value of every row and every column of this matrix is 00.

CX then asked, “WD, do you know how many 01 matrices have XOR value 00 in every row and every column!?” WD of course does not know this, so he came to ask you.

Since the answer may be very large, you only need to output the result modulo 998244353998\,244\,353.

Input Format

The first line contains an integer TT, which represents the number of test cases.

In the next TT lines, each line contains two integers n,mn, m, representing the number of rows and columns in the query.

Output Format

Output TT lines. Each line contains one integer, the answer modulo 998244353998\,244\,353.

2
2 2
2 2018
2
851481696

Hint

  • Subtask 1 (11 pts): 1T10, 1n,m41\le T\le 10,~1\le n,m\le 4.
  • Subtask 2 (43 pts): 1T5, 1n5, 1m1,0001\le T\le 5,~1\le n\le 5,~1\le m\le 1,000.
  • Subtask 3 (46 pts): 1T105, 1n,m1091\le T\le 10^5,~1\le n,m\le 10^9.

Translated by ChatGPT 5