QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#401. Factor Statistics (Ex)

الإحصائيات

You are given $q$ queries. For each query, you need to calculate the number of divisors of the binomial coefficient $\binom{n}{m}$.

Since the answer can be very large, you only need to output the result modulo $p = 10^9 + 7$.

Input

The first line contains a positive integer $q$, representing the number of queries.

Each of the next $q$ lines contains two integers $n$ and $m$, where $0 \le m \le n$.

Output

Output $q$ lines, each containing an integer representing the answer to the corresponding query.

Subtasks

For $10\%$ of the data, $q \le 10^{3}$ and $n \le 10^{3}$.

For $50\%$ of the data, $q \le 10^{5}$ and $n \le 10^{5}$.

For $100\%$ of the data, $q \le 5\times 10^{5}$ and $n \le 10^{6}$.

Examples

Input 1

4
0 0
1 0
2 1
3 2

Output 1

1
1
2
2

Input 2

5
3 2
5 3
5 4
6 2
8 3

Output 2

2
4
2
4
8

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.