#P14850. [ICPC 2022 Yokohama R] Quiz Contest

[ICPC 2022 Yokohama R] Quiz Contest

题目描述

The final round of the annual World Quiz Contest is now at the climax!

In this round, questions are asked one by one, and the competitor correctly answering the goal number of questions first will be the champion. Many questions have already been asked and answered. The numbers of questions correctly answered so far by competitors may differ, and thus the numbers of additional questions to answer correctly to win may be different.

The questions elaborated by the judge crew are quite difficult, and the competitors have completely distinct areas of expertise. Thus, for each question, exactly one competitor can find the correct answer.

Who becomes the champion depends on the order of the questions asked. The judge crew know all the questions and who can answer which, but they do not know the order of the remaining questions, as the questions have been randomly shuffled. To help the judge crew guess the champion of this year, count the number of possible orders of the remaining questions that would make each competitor win. Note that the orders of the questions left unused after the decision of the champion should also be considered.

输入格式

The input consists of a single test case of the following format.

n mn \ m a1  ana_1 \ \cdots \ a_n b1  bnb_1 \ \cdots \ b_n

Here, nn is the number of competitors and mm is the number of remaining questions. Both nn and mm are integers satisfying 1nm2×1051 \leq n \leq m \leq 2 \times 10^5. Competitors are numbered 1 through nn. The following line contains nn integers, a1,,ana_1, \ldots, a_n, meaning that the number of remaining questions that the competitor ii can answer correctly is aia_i, where i=1nai=m\sum_{i=1}^{n} a_i = m holds. The last line contains nn integers, b1,,bnb_1, \ldots, b_n, meaning that the competitor ii has to answer bib_i more questions correctly to win. 1biai1 \leq b_i \leq a_i holds.

输出格式

Let cic_i be the number of question orders that make the competitor ii the champion. Output nn lines, each containing an integer. The number on the ii-th line should be cic_i modulo a prime number 998244353=223×7×17+1998244353 = 2^{23} \times 7 \times 17 + 1. Note that i=1nci=m!\sum_{i=1}^{n} c_i = m! holds.

2 4
2 2
1 2
20
4
4 6
1 1 2 2
1 1 1 2
168
168
336
48
4 82
20 22 12 28
20 22 7 8
746371221
528486621
148054814
913602744