#AGC051D. [AGC051D] C4

[AGC051D] C4

Score : 18001800 points

Problem Statement

In the following undirected graph, count the number of walks from SS to SS that pass through the edges STST, TUTU, UVUV, VSVS (in any direction) exactly aa, bb, cc, dd times, respectively, modulo 998,244,353998,244,353.

Notes

A walk from SS to SS is a sequence of vertices v0=S,v1,,vk=Sv_0 = S, v_1, \ldots, v_k = S such that for each i(0i<k)i (0 \leq i < k), there is an edge between viv_i and vi+1v_{i+1}. Two walks are considered distinct if they are distinct as sequences.

Constraints

  • 1a,b,c,d500,0001 \leq a, b, c, d \leq 500,000
  • All values in the input are integers.

Input

Input is given from Standard Input in the following format:

aa bb cc dd

Output

Print the answer.

2 2 2 2
10

There are 1010 walks that satisfy the condition. One example of such a walk is SS \rightarrow TT \rightarrow UU \rightarrow VV \rightarrow UU \rightarrow TT \rightarrow SS \rightarrow VV \rightarrow SS.

1 2 3 4
0
470000 480000 490000 500000
712808431