Contest Duration: - (local time) (270 minutes) Back to Home
D - C4 /

Time Limit: 2 sec / Memory Limit: 1024 MB

### 注記

S から S へのウォークとは、頂点の列 v_0 = S, v_1, \ldots, v_k = S であって、各 i (0 \leq i < k) について v_iv_{i+1} を結ぶ辺があるものをいいます。 2 つのウォークは、列として異なるときに異なるとみなされます。

### 制約

• 1 \leq a, b, c, d \leq 500,000
• 入力中の全ての値は整数である。

a b c d

2 2 2 2

10

1 2 3 4

0

### 入力例 3

470000 480000 490000 500000

### 出力例 3

712808431

Score : 1800 points

### Problem Statement

In the following undirected graph, count the number of walks from S to S that pass through the edges ST, TU, UV, VS (in any direction) exactly a, b, c, d times, respectively, modulo 998,244,353.

### Notes

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

### Constraints

• 1 \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:

a b c d

2 2 2 2

### Sample Output 1

10

There are 10 walks that satisfy the condition. One example of such a walk is S \rightarrow T \rightarrow U \rightarrow V \rightarrow U \rightarrow T \rightarrow S \rightarrow V \rightarrow S.

1 2 3 4

0

### Sample Input 3

470000 480000 490000 500000

712808431