Smoke
时间限制:C/C++/Rust/Pascal 8秒,其他语言16秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

You are right, but “Smoke God” is a brand new open-world adventure game independently developed by Ding Zhenzhen. The game takes place in a fantasy world called “Litang”, where people chosen by the gods will be granted “electronic cigarettes” to guide the power of nicotine. You will play a mysterious character named “Furong Wang” and meet animal friends with different personalities and unique abilities during your free travels. Together, you will defeat powerful enemies, find lost family members, and gradually uncover the truth about “Litang”.

The harm of electronic cigarettes to the body is significant, and the damage to body depends on the level of addiction.

Let's assume that Ding Zhenzhen's current addiction level is j, and the damage to body is x. When she smokes i-th electronic cigarette:
  • There is a probability of p that the addiction level increases by one, and x is multiplied by A_j.
  • There is a probability of 1-p that the addiction level remains unchanged, and x is multiplied by B_j+C_i.

However, you do not know Ding Zhenzhen's current addiction level and the current damage to her body. You only know that if her addiction level is j, the current damage to her body is D_j.

Assuming that the initial addiction level to Ding Zhenzhen's body is equally likely to be any integer from 1 to m. Given N, what is the expected damage to her body after smoking n=1,2\cdots,N cigarettes?

输入描述:

The first line contains two integers, N, m and p (1 \leq N,m \leq 10^5, 0\leq p < 998244353), representing the number of smoking, the maximum addiction level and the probability to increase the addiction level when smoking an electronic cigarette respectively.

The second line contains m+N-1 integers, where the i-th integer A_i (0 \leq A_i < 998244353) represents the damage coefficient when the addiction level increases from i to i+1 after smoking an electronic cigarette.

The thrid line contains m+N-1 integers, where the i-th integer B_i (0 \leq B_i < 998244353) represents one of the damage coefficient when the addiction level remains at i after smoking an electronic cigarette.

The fourth line contains N integers, where the i-th integer C_i (0 \leq C_i < 998244353) represents one of the damage coefficient after smoking i-th electronic cigarette.

The fifth line contains m integers, where the i-th integer D_i (0 \leq D_i < 998244353) represents the initial damage to her body if the initial addiction level was i.

输出描述:

Output N integers for n=1,2,\cdots,N representing expected damage to her body after smoking n cigarettes, module 998244353.
示例1

输入

复制
1 1 499122177
2
2
2
1

输出

复制
3
示例2

输入

复制
2 2 546658423
260257767 682179463 892187612
142884587 872658039 89862243
117086929 104310686
342803717 47992235

输出

复制
828045057
157615404