atcoder#AGC046B. [AGC046B] Extension
[AGC046B] Extension
Score : points
Problem Statement
We have a grid with horizontal rows and vertical columns, with the squares painted white. On this grid, we will repeatedly apply the following operation:
- Assume that the grid currently has horizontal rows and vertical columns. Choose "vertical" or "horizontal".- If we choose "vertical", insert one row at the top of the grid, resulting in an grid.
- If we choose "horizontal", insert one column at the right end of the grid, resulting in an grid.
- If we choose "vertical", insert one row at the top of the grid, resulting in an grid.
- If we choose "horizontal", insert one column at the right end of the grid, resulting in an grid.
- Then, paint one of the added squares black, and the other squares white.
Assume the grid eventually has horizontal rows and vertical columns. Find the number of ways in which the squares can be painted in the end, modulo .
Constraints
- , , , and are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of ways in which the squares can be painted in the end, modulo .
1 1 2 2
3
Any two of the three squares other than the bottom-left square can be painted black.
2 1 3 4
65
31 41 59 265
387222020