#P5857. 「SWTR-3」Matrix

「SWTR-3」Matrix

Description

Little E has an n×mn \times m magic matrix. Each cell has two states: activated and not activated. At the beginning, all cells are not activated.

Little E has a magic wand and can use magic kk times. Each time magic is used, Little E needs to choose a magic cell (x,y)(x,y) and toggle the state of all magic cells in row xx and column yy. The state of (x,y)(x,y) will be toggled twice.

Now Little E wants to know how many different magic matrices can be obtained after using magic kk times.

  • Two magic matrices are different if and only if there exists at least one corresponding cell whose state is different in the two matrices.

Since the answer may be very large, output it modulo 998244353998244353.

Input Format

This problem contains multiple test cases.

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

Each test case consists of one line with three integers n,m,kn,m,k — the height of the matrix, the width of the matrix, and the number of times magic is used.

Output Format

For each test case, output a single line with one integer, representing how many different magic matrices can be obtained after using magic kk times.

11
1 1 3
4 3 5
2 3 1
123 231 132
1 1017 12345
1017 1567 1
1710 1017 999
1987 1789 375168429
101777 171077 99999
123321 200000 321123
2 2 1
1
32
6
198296574
832895500
1593639
928595966
438358858
366897935
745426660
2

Hint

"Sample Explanation"

  • For the 11st test case: no matter how the magic wand is used, at most 11 different magic matrix can be obtained.
  • For the 33rd test case: using the magic wand once on any cell can produce a different magic matrix, for a total of 2×3=62 \times 3 = 6 different magic matrices.

Constraints and Notes

Test point ID nn \leq mm \leq kk \leq
11 10910^9
22 44
353-5 200200
676-7 11 10001000 10510^5
88 10001000 11
9129-12 10510^5
132013-20 2×1052 \times 10^5 10910^9

For 100%100\% of the testdata, 1T641 \leq T \leq 64, 1n,m2×1051 \leq n,m \leq 2 \times 10^5, 1k1091 \leq k \leq 10^9.

For all test points, the time limit is 11s and the memory limit is 3232MB.

"Source"

Sweet Round 03 C
Idea & solution: ET2006。

Translated by ChatGPT 5