Binomial coefficient queries

Given M pairs N and K, print the binomial coefficient C(N, K) modulo 1,000,000,007.

Medium5CombinatoricsMathPrefix sumNo attempts yetTime limit1sMemory limit512 MB

Problem

You are given MM pairs, each made of a positive integer NN and an integer KK. For every pair, compute the binomial coefficient (NK)\binom{N}{K} modulo 1,000,000,007.

Input

The first line contains the number of pairs MM (1M100,0001 \le M \le 100{,}000).

Each of the next MM lines contains NN and KK, separated by a space (1N4,000,0001 \le N \le 4{,}000{,}000, 0KN0 \le K \le N).

Output

Print MM lines. On the ii-th line, print (NK)\binom{N}{K} modulo 1,000,000,007 for the ii-th pair, in input order.