405963: GYM102192 C City Development

Memory Limit:128 MB Time Limit:4 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. City Developmenttime limit per test4 secondsmemory limit per test128 megabytesinputstandard inputoutputstandard output

Sociologists have proposed a model to predict the development of cities in a country. The model works as follows.

Suppose, that there are n cities in the country numbered 1 through n, and there are k different levels of administrative divisions in this country. City is the lowest level (i.e., the k-th level) administrative division. Every i-th level administrative division has exactly ni cities, where , and nk = 1. Also, two cities numbered a and b belong to the same i-th level administrative division if and only if a / ni⌉ = ⌈ b / ni. It is clear that two cities belonging to the same lower level administrative division must belong to the same higher level administrative division.

The model owes the development of a city both to the city itself, and to the mutual interactions between cities. Obviously, the interaction between closer cities is stronger. We introduce the concept of lowest common administrative level (LCA for short) to characterize the closeness between two cities. Formally, for two cities numbered a, b, is defined as

In case that city a and b don't belong to any common administrative division, we define . Also, we have . Let dt(x) denote the development index of the x-th city in the t-th year, then the model says that

where ρi (0 ≤ i ≤ k) is called the interaction coefficient between two cities a, b with .

Now, given the initial development indexes of all cities, can you use this model to predict the development indexes after T years?

Input

The first line of input consists of only a single integer K (1 ≤ K ≤ 20), the number of test cases.

Each test case begins with three integers n, k, T (1 ≤ k ≤ n ≤ 3 × 105, 1 ≤ T ≤ 1018), the number of cities, the number of levels of administrative regions, and the number of years, respectively. Then follows a line with k integers n1, n2, ..., nk , the number of cities in each level of administrative divisions. The third line contains n integers d0(1), d0(2), ..., d0(n) (1 ≤ d0(i) ≤ 106), the initial development indexes of the cities. The last line of each test case contains k + 1 integers, ρ0, ρ1, ... ρk (1 ≤ ρ0 ≤ ρ1 ≤ ... ≤ ρk ≤ 106), the interaction coefficients.

It is guaranteed that the sum of n over all test cases does not exceed 106.

Output

For each test case, display a line of n integers, denoting the predicted development indexes of all cities after T years in order. Since the answers might be rather big, you should display these numbers modulo 998244353.

ExampleInput
1
4 2 1
2 1
1 3 5 6
2 4 5
Output
39 41 57 58

加入题单

算法标签: