atcoder#AGC051D. [AGC051D] C4
[AGC051D] C4
Score : points
Problem Statement
In the following undirected graph, count the number of walks from to that pass through the edges , , , (in any direction) exactly , , , times, respectively, modulo .
Notes
A walk from to is a sequence of vertices such that for each , there is an edge between and . Two walks are considered distinct if they are distinct as sequences.
Constraints
- All values in the input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2 2 2 2
10
There are walks that satisfy the condition. One example of such a walk is .
1 2 3 4
0
470000 480000 490000 500000
712808431