The nflsM Tokens (HARD)

The nflsM Tokens (HARD)

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

P1040 The nflsM Tokens (HARD)

Problem Background

See problem P1039 The nflsM Tokens (EASY) (Fib3 Queue 2).

Problem Statement

Define Fnm=Fn1m+Fn2m++Fnmm (nm),F0m=0,F1m=F2m==Fm1m=1F^{m}_{n}=F^{m}_{n-1}+F^m_{n-2}+\cdots+F^{m}_{n-m}\ (n\ge m),F^m_0=0,F^m_1=F^m_2=\cdots=F^m_{m-1}=1 with m2m\ge2.

Originally we have m=2m=2.

Given TT queries. Each query is formatted like these below:

  • 1 x means to make mm equal xx.
  • 2 n means to ask you to print FnmF^m_n modulo 998244353998244353 with the current mm.

Input

tt
Query1\text{Query}_1
Query2\text{Query}_2
Query3\text{Query}_3
     \ \ \ \ \ \vdots
Queryt\text{Query}_t

For each query, it is formatted by two integers; more see problem statement.

Output

For each query with the 2nd2^{nd} operation, print the answer.

Constraints

  • 1t1001 \le t \le 100.
  • For each query with the 1st1^{st} operation, 2x302 \le x \le 30.
  • For each query with the 2nd2^{nd} operation:
    • For 20%20\% test cases: 1n1051 \le n \le 10^5.
    • For all test cases: 1n1091 \le n \le 10^{9}.

Samples

Input 1

7
2 10
1 3
2 5
1 10
2 11
1 2
2 5

Output 1

55
7
18
5

AOCode Round #4

未参加
状态
已结束
规则
OI
题目
7
开始于
2022-04-29 18:00
结束于
2022-04-29 21:20
持续时间
3.3 小时
主持人
参赛人数
30