#ARC147F. [ARC147F] Again ABC String
[ARC147F] Again ABC String
Score : points
Problem Statement
Consider strings of length consisting of A
, B
, and C
.
Among them, find the number of strings that satisfy the following condition, modulo :
- Let be the string formed by the first characters of .
Also let , , and be the numbers of
A
's,B
's, andC
's in , respectively. For all such that , the following holds:-
You have test cases to solve.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Each case is in the following format:
Output
For each case, print the answer.
strings satisfy the condition: AAB
,AAC
,ABA
,ABC
,ACA
,ACB
,BAA
,BAC
.
Therefore the answer is .