QOJ.ac

QOJ

Limite de temps : 4 s Limite de mémoire : 128 MB Points totaux : 100

#2590. Singing, Dancing, Rap, and Basketball

Statistiques

The college of Da Zhongfeng is organizing a museum visit for its students, requiring them to line up in a queue. His students can be divided into four categories: those who like singing, those who like dancing, those who like rap, and those who like basketball. If the students at positions $k, k+1, k+2, k+3$ in the queue like singing, dancing, rap, and basketball, respectively, they will gather together to discuss Cai Xukun. Da Zhongfeng does not want this to happen, as it would make the queue appear chaotic. Da Zhongfeng wants to know how many ways the students can be arranged such that no students gather to discuss Cai Xukun. Two student queues are considered different if and only if at least one position in the two queues has a student with a different preference. Since there may be many valid queues, output the number of ways modulo $998244353$.

Input

The input consists of a single line. The line contains 5 integers: the first integer $n$ represents the number of students Da Zhongfeng's college is organizing to visit the museum. The following four integers $a, b, c, d$ represent the number of students who like singing, dancing, rap, and basketball, respectively. It is guaranteed that $a + b + c + d \geq n$.

Output

For each test case, output a single integer representing the number of different student queues you can arrange such that no students in the queue gather to discuss Cai Xukun. The result should be modulo $998244353$.

Constraints

  • For $20\%$ of the data, $n = a = b = c = d \leq 500$.
  • For $100\%$ of the data, $n \leq 1000$, $a, b, c, d \leq 500$.

Examples

Input 1

4 4 3 2 1

Output 1

174

Input 2

996 208 221 132 442

Output 2

442572391

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.