8550: Find the Number of Paths

内存限制:128 MB 时间限制:8 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:2 通过:1

题目描述

Huah has n+kn+k cities numbered 1,2,.... ,n+k the city i(1i<n+k) to the city i+1 has n+k-idistinct one-way roads.

For each x=1,2,...,n-1,the city i(x<in+k) to the city ix has ax distinct one-way roads.

For m=k+1,k+2,... ,k+n,find the number of paths from city k+1 to city mm that pass through exactly k number of roads.

Two paths are distinct when and only if the sequence of edges they pass through is distinct and the answer is modulo 998244353

输入格式

First line has one integer T(1T14), indicating there are T test cases. In each case:

First line input two integers n,k(2n2×105,1k2×105).

Second line n-1 integers a1,a2,...,an1(0ai998244352).

There is a blank line between casei(1i<T) and case i+1.

Input guarantee (n+k)1006769.

输出格式

In each case, output a row of n integers with the i-th integer being the answer when m=k+i.

输入样例 复制

4
3 2
1 2

3 1
1 2

5 10
2 3 3 3

3 3
166374059 748683265

输出样例 复制

5 0 2
0 2 0
114307026 825469567 425461680 73846080 5140800
5 2 0