9574: ABC242 —— F - Black and White Rooks
[Creator : ]
Description
Consider placing $B$ black rooks and $W$ white rooks on a grid with $N$ horizontal rows and $M$ vertical columns.
A placement of the rooks satisfying all of the following conditions is called a good placement.
- All $B+W$ rooks are placed on the grid.
- At most one rook is placed in the same square.
- There is no pair of white rook and black rook attacking each other. That is, there is no pair of white rook and black rook such that one of them can reach the square in which the other is placed in one move.
Here, in one move, a rook can reach any square that is on a horizontal or vertical line from its current position and is reachable without jumping over another rook.
How many good placements are there? Since this count can be enormous, print it modulo $998244353$.
Rooks in the same color are not distinguished.
A placement of the rooks satisfying all of the following conditions is called a good placement.
- All $B+W$ rooks are placed on the grid.
- At most one rook is placed in the same square.
- There is no pair of white rook and black rook attacking each other. That is, there is no pair of white rook and black rook such that one of them can reach the square in which the other is placed in one move.
Here, in one move, a rook can reach any square that is on a horizontal or vertical line from its current position and is reachable without jumping over another rook.
How many good placements are there? Since this count can be enormous, print it modulo $998244353$.
Rooks in the same color are not distinguished.
Input
Input is given from Standard Input in the following format:
```
$N$ $M$ $B$ $W$
```
```
$N$ $M$ $B$ $W$
```
Output
Print the count modulo $998244353$.
Constraints
- $1 \leq N,M \leq 50$
- $1 \leq B,W \leq 2500$
- $B+W \leq N \times M$
- All values in input are integers.
- $1 \leq B,W \leq 2500$
- $B+W \leq N \times M$
- All values in input are integers.
Sample 1 Input
2 2 1 1
Sample 1 Output
4
There are four good placements as follows.
Sample 2 Input
1 2 1 1
Sample 2 Output
0
There may be no good placement.
Sample 3 Input
40 40 30 30
Sample 3 Output
467620384