QOJ.ac

QOJ

时间限制: 2 s 内存限制: 512 MB 总分: 100

#4903. Bacteria

统计

Scientists have built a massive bacterial incubator. This incubator is a large rectangular parallelepiped with dimensions $n, m, k$, divided into $n \times m \times k$ small cells of size $1 \times 1 \times 1$. We establish a three-dimensional Cartesian coordinate system, using $(x, y, z)$ ($1 \leq x \leq n, 1 \leq y \leq m, 1 \leq z \leq k$) to describe the position of a small cell.

At the beginning of the experiment, each cell contains exactly $1$ bacterium. Every day thereafter, all bacteria divide. Suppose a bacterium at $(x, y, z)$ divides; it produces $6$ new bacteria, which move to the cells at $(x+1, y, z), (x-1, y, z), (x, y+1, z), (x, y-1, z), (x, y, z+1), (x, y, z-1)$. The original bacterium dies. Specifically, if a cell that a bacterium moves to does not exist, that bacterium dies instantly.

The experiment lasts for $d$ consecutive days. After $d$ days, the scientists want to know: how many bacteria are in the cell at $(a, b, c)$? Since the answer may be very large, you only need to output the value modulo $998244353$.

Input

A single line containing seven positive integers $d, n, m, k, a, b, c$.

Output

A single integer representing the answer modulo $998244353$.

Examples

Input 1

2 2 2 3 1 1 1

Output 1

10

Note 1

After the first day, it can be determined that all cells with $z=2$ have exactly $4$ bacteria, and all other cells have exactly $3$ bacteria. After the second day, the number of bacteria in cell $(1, 1, 1)$ is equal to the sum of the bacteria in cells $(1, 1, 2), (1, 2, 1), (2, 1, 1)$ at the end of the first day, which is $10$.

Input 2

2 2 2 3 1 1 2

Output 2

14

Input 3

50 49 44 48 49 15 25

Output 3

544847893

Input 4

120000 49997 49997 49993 46278 44140 26931

Output 4

139550295

Constraints

For all data, $1 \leq d, n, m, k \leq 1.2 \times 10^5, 1 \leq a \leq n, 1 \leq b \leq m, 1 \leq c \leq k$.

This problem consists of several subtasks. You must pass all test cases in a subtask to receive the points for that subtask.

  • Subtask 1 ($5$ points): $d, n, m, k \leq 50$.
  • Subtask 2 ($10$ points): $d, n, m, k \leq 5 \times 10^3$. Depends on Subtask 1.
  • Subtask 3 ($15$ points): $m = k = 1$.
  • Subtask 4 ($10$ points): $k = 1, n, m \geq d$.
  • Subtask 5 ($15$ points): $k = 1, n, m \geq \frac{d}{10}$. Depends on Subtask 4.
  • Subtask 6 ($35$ points): $k = 1$. Depends on Subtasks 3, 4, and 5.
  • Subtask 7 ($10$ points): No special restrictions. Depends on Subtasks 1, 2, 3, 4, 5, and 6.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.