atcoder#AGC046B. [AGC046B] Extension

[AGC046B] Extension

Score : 600600 points

Problem Statement

We have a grid with AA horizontal rows and BB vertical columns, with the squares painted white. On this grid, we will repeatedly apply the following operation:

  • Assume that the grid currently has aa horizontal rows and bb vertical columns. Choose "vertical" or "horizontal".- If we choose "vertical", insert one row at the top of the grid, resulting in an (a+1)×b(a+1) \times b grid.
    • If we choose "horizontal", insert one column at the right end of the grid, resulting in an a×(b+1)a \times (b+1) grid.
  • If we choose "vertical", insert one row at the top of the grid, resulting in an (a+1)×b(a+1) \times b grid.
  • If we choose "horizontal", insert one column at the right end of the grid, resulting in an a×(b+1)a \times (b+1) grid.
  • Then, paint one of the added squares black, and the other squares white.

Assume the grid eventually has CC horizontal rows and DD vertical columns. Find the number of ways in which the squares can be painted in the end, modulo 998244353998244353.

Constraints

  • 1AC30001 \leq A \leq C \leq 3000
  • 1BD30001 \leq B \leq D \leq 3000
  • AA, BB, CC, and DD are integers.

Input

Input is given from Standard Input in the following format:

AA BB CC DD

Output

Print the number of ways in which the squares can be painted in the end, modulo 998244353998244353.

1 1 2 2
3

Any two of the three squares other than the bottom-left square can be painted black.

2 1 3 4
65
31 41 59 265
387222020