P28820 [洛谷] Playing Games
省选
题目描述

Problem Description

Alice and Bob are playing a game again.

For a round of the game, Alice starts with a sequence \(a\) of length \(n\), and Bob starts with a sequence \(b\) of length \(m\). Each of them randomly picks a number from their respective sequences, denoted as \(a_x\) and \(b_y\). The \(k\)-th value of this game is defined as \((a_x + b_y)^k\).

Finding the game too dull, they ask you to help calculate the expected \(i\)-th value for each \(i\) from 1 to \(t\).

Since the answer could be very large, you only need to output the result modulo \(998244353\).

Input Format

The first line contains two integers \(n, m\) (\(1 \leq n, m \leq 10^5\)), representing the lengths of Alice's and Bob's sequences, respectively.

The next line contains \(n\) numbers, where the \(i\)-th number is \(a_i\) (\(0 \leq a_i < 998244353\)), representing Alice's sequence.

The following line contains \(m\) numbers, where the \(j\)-th number is \(b_j\) (\(0 \leq b_j < 998244353\)), representing Bob's sequence.

The last line contains an integer \(t\) (\(1 \leq t \leq 10^5\)), as described above.

Output Format

Output \(t\) lines, where the \(i\)-th line represents the expected \(i\)-th value of the game.

Sample Input and Output

Input Sample #1

1 1
1
2
3

Output Sample #1

3
9
27

Input Sample #2

2 8
764074134 743107904
663532060 183287581 749169979 7678045 393887277 27071620 13482818 125504606
6

Output Sample #2

774481679
588343913
758339354
233707576
36464684
461784746
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 1 1 2 3
样例输出
3 9 27