시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 5 | 2 | 2 | 100.000% |
Kevin is playing cards and now he needs to shuffle cards 𝑚m times. Now let's describe the rule of the ith shuffle.
For the ith shuffle:
Now we have Q questions for you. You have to tell us after m times of shuffles, what's the expected score of some specific positions' card. Note that for card i, let's denote its score as f(i). In this problem, f(i) equals to either i or i2.
The first line contains three integers n, m, type. When type = 1, f(i) = i. When type = 2, f(i) = i2.
The following line contains m integers A1 … Am.
The following line contains an integer Q.
In the following Q lines, each line contains an integer ci (1 ≤ ci ≤ n), indicating that Kevin wants to know the expected score of the ci position from top.
For each query, output a single integer on a single line as the answer. If the answer is A/B, please print C (0 ≤ C < 998244353) where A ≡ C × B (mod 998244353).
For all test cases, 3 ≤ n ≤ 107, 1 ≤ m, Q ≤ 5 × 105, 0 ≤ Ai ≤ n, type ∈ [1,2].
4 1 1 3 1 1
249561090