#P4705. 玩游戏
玩游戏
Description
Alice and Bob are playing a game again.
In one game, first Alice receives a sequence of length , and Bob receives a sequence of length . Then they each randomly pick one number from their own sequence, denoted . The -th value of this game is defined as .
Because they find this game too boring, they ask you to compute, for , the expected -th value of a game.
Since the answer can be large, you only need to output the result modulo .
Input Format
The first line contains two integers , representing the lengths of Alice’s and Bob’s sequences.
The next line contains numbers, where the -th number is , representing Alice’s sequence.
The next line contains numbers, where the -th number is , representing Bob’s sequence.
The next line contains one integer , as described above.
Output Format
Output lines, where the -th line is the expected -th value of a single game.
1 1
1
2
3
3
9
27
2 8
764074134 743107904
663532060 183287581 749169979 7678045 393887277 27071620 13482818 125504606
6
774481679
588343913
758339354
233707576
36464684
461784746
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号