We are given 4 integers N,M ,Q and Z.
Initially,the matrix has all zeroes in it.
We have to perform Q operations on the matrix.
In each operation, any cell of the matrix can be selected(same cell can be selected multiple times) .
Once a cell (x,y) is selected, you have to add '1' to all the elements of row 'x' and column 'y' .
After all the operations are done , there should be exactly "Z" numbers in the matrix which are odd.
How many sequences of Q-operations are possible for given $N,M,Q,Z$
If we start by choosing the cell (1,1), the matrix becomes
Now we have two options ― we can choose either even-valued cell. If we choose (1,1) again, the matrix becomes
If we choose (2,2) instead, it becomes
For each of the other three possible initial cells, there are also two cells we can choose in the second operation, which is 4⋅2=8 ways in total.
$N$ and $M$ are dimensions of the matrix.
What have I tried:-
Number of ways to select 'Q' distinct points on a matrix:-
Number of ways to select 'Q' points on a matrix with repetition allowed:-