Měilì

Time limit: 0.4s Memory limit: 256MB Input: Output:

We have two generators made by AI. One is wrong on one test, the other is wrong on another - 马德尤

Task

The organizing committee decided to be very short, brief and terse with the statement of this problem, because of many obvious reasons.

We call an array of integer elements chic if the sum of its elements is even.

Consider (N,M)\nabla(N, M) = the number of arrays of NN elements from {0,1,,M}\{0, 1, \ldots, M\} such that the chosen array has an even number of chic subarrays.

Given NN and MM, compute

i=0M(N,i)mod998244353.\sum_{i=0}^M \nabla(N, i) \bmod 998244353.

Input data

You will have to answer TT tests. On the next TT lines, you will be given two numbers, NN and MM, with their meaning explained above.

Output data

You will have to print TT integers - the answer for each case.

Constraints and clarifications

  • 1T41 \leq T \leq 4
  • 1N1051 \leq N \leq 10^5, for all tests;
  • 1M1091 \leq M \leq 10^9, for all tests;
  • A subarray of an array VV with NN elements is any contiguous subsequence of it (that is, of the form Vl,Vl+1,,VrV_l,V_{l+1},\ldots, V_r for some ll and rr with 0lr<N0 \leq l \leq r < N).
# Score Constraints
1 30 N,M1 000N, M \leq 1 \ 000
2 10 M=1M = 1
3 60 No further restrictions.

Example

stdin

2
1 3
2 3

stdout

4
0

Explanation

There are T=2T = 2 cases.

For the first case, one can compute that (1,0)=0,(1,1)=1,(1,2)=1\nabla(1, 0) = 0, \nabla(1, 1) = 1,\nabla(1,2) = 1 and (1,3)=2\nabla(1, 3) = 2. Thus, the sum is (0+1+1+2)mod998244353=4(0+1+1+2) \bmod 998244353 = 4.

For the second case, it can be proven that there exist no arrays that satisfy the \textit{chic} condition.

Log in or sign up to be able to send submissions!