#P5159. Count 01 Matrices with Zero XOR in Rows and Columns

    ID: 18397 Type: Default 1000ms 256MiB

Count 01 Matrices with Zero XOR in Rows and Columns

Count 01 Matrices with Zero XOR in Rows and Columns

You are given two positive integers \(n\) and \(m\). Consider an \(n \times m\) binary (01) matrix where each element is either 0 or 1.

The matrix must satisfy the following conditions:

  • For each row \(i\): \(a_{i,1} \oplus a_{i,2} \oplus \cdots \oplus a_{i,m} = 0\).
  • For each column \(j\): \(a_{1,j} \oplus a_{2,j} \oplus \cdots \oplus a_{n,j} = 0\).

Here, \(\oplus\) denotes the bitwise XOR operation. It is known that one of these \(n+m\) constraints is redundant. Hence, the number of free variables is \(n \times m - (n + m - 1) = (n-1)(m-1)\), and each free variable can be independently chosen as 0 or 1.

Your task is to compute the total number of matrices satisfying the above conditions, which is \(2^{(n-1)(m-1)}\). Since the answer might be very large, output the result modulo \(998\,244\,353\).

inputFormat

The first line contains two integers (n) and (m).

outputFormat

Output a single integer denoting the number of 01 matrices such that the XOR of all elements in every row and every column is 0, modulo (998244353).

sample

1 1
1