F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Guess Or Not 2

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 4    Accepted Submission(s): 3


Problem Description
Bob has a generator which can generate a discrete probability distribution according to a given vector and a parameter.

This generator can be described as follows:



Now, given a vector $y[1..k]$, compute the probability density of the discrete probability distribution $y'[1..k]$ the algorithm output at the given vector $y[1..k]$. More specificly, compute the probability density $f_{GENERATE(x,k,t)}(y)$. Here, we see $GENERATE(x,k,t)$ as a random vector.

You should print the answers module $998244353$.
 

Input
The first line contains the only integer $T$ denoting the number of test cases.

Each of the following $T$ test cases begins with two integers $k$ and $t$ in the first line, $k$ intergers $x_i$ follow in the second line and $k$ intergers $z_i$ follow in the third line.

Here, you can compute $y_i$ by $y_i = z_i / \sum_{j} z_j$.

Note that $\sum k \le 10^6, k \in [2,10^6], t, x_i, z_i \in [1,998244353)$.
 

Output
For each test case, print the only integer in one line denoting the required probability density module $998244353$.

Note that we guarantee the answers always exsit, i.e., $\sum z_i$ $mod$ $998244353$ $\ne 0$.
 

Sample Input
2 3 1 1 1 1 2 2 2 3 2 1 1 1 1 2 3
 

Sample Output
2 596788047
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 06:59:33, Gzip enabled