QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 256 MB Puntuación total: 100

#15595. Supernova Particle Cannon·Modified

Estadísticas

The inventor SHTSC, who once invented the brain-hole therapy device and the super particle cannon, has unveiled his new invention: the Super Particle Cannon Kai—a mysterious device capable of firing a more powerful particle stream.

Compared to the super particle cannon, the Super Particle Cannon Kai has a fundamental improvement in power. It has three parameters $n$, $k$, and an implied third parameter. It fires a particle stream with power $C(n, i) \pmod{2333}$ at each position $i$ from $0$ to $k$.

Now, SHTSC has provided the parameters for his Super Particle Cannon Kai. You are asked to calculate the sum of the powers of the particle streams fired, modulo $2333$.

Input

The first line contains an integer $t$, representing the number of test cases.

Following this are $t$ lines, each containing two integers $n$ and $k$, as described in the problem statement.

Output

For each test case, output a single integer on a new line, representing the sum of the powers of the particle streams modulo $2333$.

Constraints

  • For $10\%$ of the data: $n, k \le 1000$.
  • For $30\%$ of the data: $n, k \le 10^6$.
  • For $50\%$ of the data: $n \le 10^{18}$, $k \le 10^6$, $t = 1$.
  • For $70\%$ of the data: $t \le 100$.
  • For $100\%$ of the data: $n, k \le 10^{18}$, $k \le n$, $t \le 10^5$.

Examples

Input 1

1
5 5

Output 1

32

Input 2

1
10 7

Output 2

968

Input 3

5
100 50
101 51
102 52
103 53
104 54

Output 3

1487
2186
329
1901
254

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.