atcoder#AGC058D. [AGC058D] Yet Another ABC String

[AGC058D] Yet Another ABC String

Score : 10001000 points

Problem Statement

You are given integers AA, BB, and CC. How many strings SS consisting of A, B, and C satisfy all of the following conditions? Find the count modulo 998244353998244353.

  • The number of occurrences of A, B, and C in SS are AA, BB, and CC, respectively.
  • SS contains none of ABC, BCA, and CAB as a (contiguous) substring.

Constraints

  • 1A,B,C1061 \leq A,B,C \leq 10^6
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

AA BB CC

Output

Print the answer.

1 1 1
3

The three strings that satisfy the conditions are ACB, CBA, and BAC.

2 2 2
42
96 11 46
818015722
125132 102271 152064
128086069