atcoder#ABC273G. [ABC273G] Row Column Sums 2
[ABC273G] Row Column Sums 2
Score : points
Problem Statement
Find the number, modulo , of square matrices of size whose elements are non-negative integers, that satisfy both of the following two conditions:
- for all , the sum of the elements in the -th row is ;
- for all , the sum of the elements in the -th column is .
Note that and given in the input are integers between and (see Constraints).
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
3
1 1 1
0 1 2
3
The following matrices satisfy the conditions:
0 1 0
0 0 1
0 0 1
0 0 1
0 1 0
0 0 1
0 0 1
0 0 1
0 1 0
3
1 1 1
2 2 2
0
18
2 0 1 2 0 1 1 2 1 1 2 0 1 2 2 1 0 0
1 1 0 1 1 1 1 1 1 1 1 1 2 1 1 0 2 2
968235177
Be sure to print the count modulo .