Universal Cup Judging System

Universal Cup

Limite de temps : 2.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓
Statistiques

You are given integers $H, W, A, B, C, D$.

There is a grid with $H$ rows and $W$ columns. The cell in the $i$-th row from the top and the $j$-th column from the left is called cell $(i, j)$.

Each cell is colored either white or black. Cell $(i, j)$ is black if and only if $A \le i \le B$ and $C \le j \le D$; otherwise, it is white.

You place lights on some of the white cells of this grid. A light placed on a white cell $(i, j)$ illuminates all white cells that satisfy both of the following conditions:

  • They are in the same row or the same column as cell $(i, j)$.
  • There is no black cell between cell $(i, j)$ and that cell.

A placement of lights is said to be valid if it satisfies the following two conditions:

  • Every white cell is illuminated by at least one light.
  • No cell that has a light is illuminated by any other light.

Find the number of valid placements of lights, modulo $998244353$.

Input

The input is given in the following format:

H W A B C D
  • All input values are integers.
  • $1 \le A \le B \le H \le 5 \times 10^5$
  • $1 \le C \le D \le W \le 5 \times 10^5$
  • $(A, B) \ne (1, H)$
  • $(C, D) \ne (1, W)$

Output

Output the answer.

Examples

Input 1

3 3 2 2 2 2

Output 1

7

Input 2

2 3 1 1 1 2

Output 2

3

Input 3

500000 500000 100000 200000 100000 250000

Output 3

360665510

Note

In the first example, there are exactly $7$ valid placements of lights. Cells with lights and white cells illuminated by lights are shown in green in the figures.

problem_16233_1.png

Some placements do not satisfy the conditions: in the left case, there exists at least one white cell that is not illuminated by any light; in the right case, there is a white cell with a light that is illuminated by another light. Both cases are invalid.

problem_16233_2.png

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.