时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
Special Judge, 64bit IO Format: %lld

题目描述

wzj is working on a cloze test. For those who are not familiar with cloze tests, here is an introduction:

A cloze test consists of n questions, each with exactly m options. A sequence of n positive integers between 1 and m is called an answer set.

The standard answer to the cloze test is a specific answer set. The score of an answer set is defined as the number of positions where it matches the standard answer. An answer set is called balanced if each integer from 1 to m appears exactly the same number of times (in this problem, n is guaranteed to be a multiple of m). The standard answer is always balanced.

Here is some information about wzj:

wzj has a clear understanding of his own level in cloze tests. He knows that he has a probability p_i of scoring exactly i. This means he has a probability p_0 of getting all wrong, a probability p_1 of getting exactly 1 correct, ..., and a probability p_n of getting all correct. wzj selects among answers with the same score uniformly at random. That is, wzj's process of completing the cloze test is as follows: he first randomly determines his score according to the probabilities p_i, and then randomly selects one answer set among those that achieve this score.

Given this background:

One day, wzj completed a cloze test and was pleasantly surprised to find that his answer was balanced. Calculate the expected value of his score. Output the result modulo 998244353.


输入描述:

The first line contains two positive integers n and m, indicating the number of questions and the number of options for each question. It is guaranteed that n is a multiple of m.
The second line contains n+1 non-negative integers p_0, p_1, \cdots, p_n, representing the probability of wzj scoring each possible score. The sum of p_i is guaranteed to be 1 modulo 998244353.

输出描述:

A single integer representing the expected value of wzj's score modulo 998244353.
示例1

输入

复制
4 2
0 0 499122177 0 499122177

输出

复制
598946615
示例2

输入

复制
6 2
752799823 916109267 344699104 500885563 291014794 599627729 587841133

输出

复制
333821851
示例3

输入

复制
9 9
926490943 986291687 543042765 643699715 240607358 250532305 505125659 594335210 257420759 43675365

输出

复制
635318919

备注:

1 \leq n, m \leq 2000.
0 \leq p_i < 998244353.
Ensure that the denominator is not a multiple of 998244353.