luogu#P5239. 回忆京都

回忆京都

Background

106th place in the Music section of the 15th Touhou Popularity Poll.

51st place in the 4th domestic poll survey of people who do not know Touhou voting on Touhou original tracks.

The chorus of Recalling Kyoto is so good, and Touhou Bunkachou is also so good.

Problem Description

While collecting materials, Shameimaru Aya discovered something interesting, called the binomial coefficient.

The definition of a binomial coefficient is as follows: from nn distinct elements, choose any mm elements (mn)(m \leq n) to form a group. This is called a combination of choosing mm elements from nn distinct elements. The number of all such combinations is the binomial coefficient.

The formula for computing the binomial coefficient is: Cnm=n!m!×(nm)!\mathrm C^m_n=\dfrac{n!}{m! \times (n-m)!}. It is guaranteed that mnm \leq n, and it represents the number of ways to choose mm elements from nn elements.

To make it easier to understand, here is an example: in the third playthrough (week) of th16.5 Violet Detector, each day’s battle has 44 characters appearing in pairs. Then clearly there are C42=6\mathrm C^2_4=6 ways to form pairs.

For a more detailed explanation, please see the sample explanation.

Since she is curious about new things, she wants to know what Cnm\mathrm C^m_n is. This is very easy for her, so she solved it instantly at a glance. Therefore, she decided to compute the following expression:

i=1nj=1mCji\sum_{i=1}^n \sum_{j=1}^m \mathrm C^i_j

When i>ji>j, Cji\mathrm C^i_j is defined to be 00.

She quickly computed it, but she is not very confident in her answer, so you decide to help her. However, she, being idle and looking for something to do, computed the result qq times for different n,mn,m. So this can only be left to you. Since you do not plan to truly help her, you do not need to take the answer modulo 998244353998244353, nor modulo 6412364123. You only need to tell her the answer modulo 1926081719260817.

Input Format

The first line contains a non-negative integer qq, indicating that there are qq queries.

Starting from the second line, there are qq lines in total. Each line contains two non-negative integers n,mn,m, with the meaning as described in the statement.

Output Format

Output qq lines in total. For each query, output one answer.

5
2 3
1 4
4 3
2 5
3 5
10
10
11
35
50

Hint

Test Point ID qq nn mm
11 =0=0 Does not exist
232\sim 3 10\le 10 10\le 10
464\sim 6 103\le 10^3
7107\sim 10 104\le 10^4

Sample explanation about binomial coefficients.

For example, if Remilia, Flandre, Hijiri Byakuren, and Toyosatomimi no Miko appear in combinations on that day, there will be six cases:

  1. Remilia x Flandre 背德组\text{\color{white}背德组}

  2. Toyosatomimi no Miko x Hijiri Byakuren 宗教组\text{\color{white}宗教组}

  3. Remilia x Toyosatomimi no Miko.

  4. Flandre x Toyosatomimi no Miko.

  5. Remilia x Hijiri Byakuren.

  6. Flandre x Hijiri Byakuren.

Translated by ChatGPT 5