#agc058d. [agc058_d]Yet Another ABC String
[agc058_d]Yet Another ABC String
Problem Statement
You are given integers , , and . How many strings consisting of A
, B
, and C
satisfy all of the following conditions? Find the count modulo .
- The number of occurrences of
A
,B
, andC
in are , , and , respectively. - contains none of
ABC
,BCA
, andCAB
as a (contiguous) substring.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
1 1 1
Sample Output 1
3
The three strings that satisfy the conditions are ACB
, CBA
, and BAC
.
Sample Input 2
2 2 2
Sample Output 2
42
Sample Input 3
96 11 46
Sample Output 3
818015722
Sample Input 4
125132 102271 152064
Sample Output 4
128086069