8986: Smoke

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述


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 jjj, and the damage to body is xxx. When she smokes iii-th electronic cigarette:
  • There is a probability of ppp that the addiction level increases by one, and xxx is multiplied by AjA_jAj.
  • There is a probability of 1−p1-p1p that the addiction level remains unchanged, and xxx is multiplied by Bj+CiB_j+C_iBj+Ci.

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 jjj, the current damage to her body is DjD_jDj.

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

输入格式


The first line contains two integers, N,mN, mN,m and ppp (1≤N,m≤105,0≤p<9982443531 \leq N,m \leq 10^5, 0\leq p < 9982443531N,m105,0p<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−1m+N-1m+N1 integers, where the iii-th integer AiA_iAi (0≤Ai<9982443530 \leq A_i < 9982443530Ai<998244353) represents the damage coefficient when the addiction level increases from iii to i+1i+1i+1 after smoking an electronic cigarette.

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

The fourth line contains NNN integers, where the iii-th integer CiC_iCi (0≤Ci<9982443530 \leq C_i < 9982443530Ci<998244353) represents one of the damage coefficient after smoking iii-th electronic cigarette.

The fifth line contains mmm integers, where the iii-th integer DiD_iDi (0≤Di<9982443530 \leq D_i < 9982443530Di<998244353) represents the initial damage to her body if the initial addiction level was iii.

输出格式


Output NNN integers for n=1,2,⋯,Nn=1,2,\cdots,Nn=1,2,,N representing expected damage to her body after smoking nnn cigarettes, module 998244353998244353998244353.

输入样例 复制

1 1 499122177
2
2
2
1

输出样例 复制

3

分类标签