7468: Game on a Circle

内存限制:128 MB 时间限制:3 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

There are nstones on a circle, numbered from 1to nin the clockwise direction such that the next of the i-th stone is the (i+1)-th one (i=1,2,…,n−1)and the next of the n-th stone is the first one.
At the beginning of this game, all the stones exist. You will start from the first stone, and then repeatedly do the following operation until all the stones have been erased:
    1. erase the current stone with probability p, and
    2. move to the next stone that hasn't been erased in the clockwise direction.
Now your task is, for i=1,2,…,n, to calculate the probability that the i-th earliest erased stone is the c-th one.
Due to the precision issue, you are asked to report the probabilities in modulo 998244353(223×7×17+1, a prime). For example, if the irreducible fraction of some output value is xy, then you are asked to output the minimum possible non-negative integer zsuch that x≡yz(mod998244353).

输入格式

There are several test cases.
The first line contains an integer T(1≤T≤100), denoting the number of test cases. Then follow all the test cases.
For each test case, the only line contains four integers n, a, band c(1≤c≤n≤106,0<a<b<998244353), representing that the number of stones is n, the probability pis aband the special stone is the c-th one.
It is guaranteed that the sum of nin all test cases is no larger than 106.
It is also guaranteed that (1−p)i≢1(mod998244353)for i=1,2,…,nin each test case.

输出格式

For each test case, output nlines, where the i-th line contains an integer, denoting the probability, in modulo 998244353, that the i-th earliest erased stone is the c-th one.

输入样例 复制

2
3 1 2 2
4 1 3 3

输出样例 复制

713031681
570425345
713031681
706449850
560148451
952979832
775154927

数据范围与提示

For the first sample case, the irreducible fractions of the output values are [2/7, 3/7, 2/7]. For the second sample case, the irreducible fractions of the output values are [12/65, 356/1235, 333/1235, 318/1235].