8558: Find different

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

题目描述

You are given two integers nn,mm.

Two array x=x0,x1,,xl1,y=y0,y1,, yl1 of length ll are considered different if xx couldn't become yy by performing the following operations any number of times:

 operation 1:: Change xx to bb , for each bi = (xi+1) mod m

operation 2:: Change xx to bb , for each bi = x(i+1) mod l

As an example, if m=3, l=3(0,2,2) and (0,1,0) are considered not different because (0,2,2) can become (0,1,0) as follows: 

(0,2,2)operation 1(1,0,0)operation 2(0,0,1)operation 2(0,1,0)

For each i, find the number of different integer array a of length i satisfied j(0,1,,i1),0ajm1.

Since the answer may be too large, print it modulo 998244353.

输入格式

The first line of the input contains one integer T ((1T100))--- the number of test cases. Then T testcases follow.

Each of the next T lines contains two integers n,m 1n,m100000)).

The sum of n over all testcases doesn't exceed 106.

输出格式

For each testcase,output one line contains n integers, separated by space, the ii-th integer indicating the number of different a of length ii, modulo 998244353.
Don‘t have spaces at the end of the line

输入样例 复制

2
10 2
10 100000

输出样例 复制

1 2 2 4 4 8 10 20 30 56
1 50001 338600275 682529035 345997022 799071125 767573961 525777344 672451750 695859947