LearnPy Hub
← Arena
AdvancedRating 1600

Combinations Mod Prime

Answer q queries of C(n, r) mod 1 000 000 007, with n ≤ 10⁵.

Input

q, then q lines 'n r' (0 ≤ r ≤ n ≤ 10⁵).

Output

q lines.

Sample 1

Input
3
5 2
10 0
10 10
Output
10
1
1

Sample 2

Input
1
100000 50000
Output
149033233
solution.py
Output appears here
Combinations Mod Prime · Python Arena problem · LearnPy Hub