#Q236. 「一本通 6.6 练习 5」Combination

「一本通 6.6 练习 5」Combination

Description

Original source: BZOJ 2982

LMZ has nn distinct friends, and every night he selects mm of them for [censored], ensuring that each night's selection is different. How many such nights can LMZ sustain? Note that LMZ's year consists of 1000710007 days, so he wants to know the answer modulo 1000710007.

Input Format

The first line contains an integer tt, indicating the number of test cases.

Each of the next tt lines contains two integers nn and mm, as described in the problem statement.

Output Format

Output tt lines, each containing a single number, which is the value of (nm)mod10007\binom{n}{m} \bmod 10007.

Sample 1

4
5 1
5 2
7 3
4 2

5
10
35
6

Data Range and Hints

For all test cases, 1t2001\le t\le 200, 1mn2×1081\le m\le n\le 2\times 10^8.