Under construction

Still being built. Things may change

Kilk

Time limit2sMemory limit512 MB

Summary
Count the strings with x letters a and y letters b whose longest run of equal letters is as small as possible, modulo 998244353.
Level

Medium6 of 10

Topics
Combinatorics, Math, String
Solved
No attempts yet

Problem

Find the number of strings that consist of xx letters a and yy letters b, such that the length of the longest substring of equal letters is as small as possible among all such strings. Display the count modulo 998244353998244353.

Input

The first line contains a single integer tt (1≤t≤1051 \le t \le 10^5), the number of test cases. Each of the next tt lines contains two integers xx and yy (1≤x,y≤20001 \le x, y \le 2000).

Output

For each test case, print the required number.

Hint

In the first test case, the strings are abbabb, bababb, babbab, bbaabb, bbabab, and bbabba. Each of these strings has a longest run of equal letters of length 2, and no string with 2 letters a and 4 letters b has a smaller value.

Examples1

  1. Example 1

    Input
    5
    2 4
    7 8
    7 7
    9 3
    239 58
    
    Expected output
    6
    1
    2
    20
    868098448