Given a set of  N  natural numbers 1,2,3........N and Q query.For each query you have to calculate the total number of subset in which  Ith.
number of set come at Kth postion.Elements of every subset should be in sorted order.
The answer could  be very large so you have to print answer modulo 1e9+7.


-----Input:-----
- The first line of input cotains a single integer T denoting the number of test cases.
- For every test case it contains two number N and Q.
- Next Q line contains two number I and K.

-----Output:-----
For each test case print required answer.

-----Constraints and Subtasks:-----
- 1<=T<=5
- 1<=N, K<=4000
- 1<=Q<=1000000
Subtask 3: 5 points
- 1<=T<=5
- 1<=N, K<=16
- 1<=Q<=1000
Subtask 1: 25 points
- T=1
- 1<=N, K<=4000
- 1<=Q<=100000
Subtask 2: 70 points
- Original Constraints.

-----Example:-----
Input:

1

3 3

1 2

2 1

3 2

Output:

0

2

2

-----Explanation:-----
For N=3

total subsets are:

{1}

{2}

{3}

{1,2}

{1,3}

{2,3}

{1,2,3}

Now we can see that for I=1 and K=2 there is no subset in which 1 come at 2nd position so the answer is Zero for that query.

For 2nd query I=2 and K=1 there are two subset i.e {2,3} and {2} in which 2 come at 1st position.

Same for 3rd querry there is two subset i.e{1,3} and {2,3}.

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
mm = 1000000007

def abc(a, b):
	c = 1
	d = 1
	for i in range(b):
		c = c * a % mm
		a -= 1
		d = d * (i + 1)
	return c * pow(d, mm - 2, mm) % mm
t = int(input())
while t > 0:
	(n, m) = [int(x) for x in input().split()]
	while m > 0:
		(a, b) = [int(x) for x in input().split()]
		if b > a:
			print(0)
		else:
			r = abc(a - 1, b - 1)
			print(r * pow(2, n - a, mm) % mm)
		m -= 1
	t -= 1


def modInv(b, p):
	return pow(b, p - 2, p)

def modNcr(n, r, p):
	fact = [1] * (n + 1)
	for i in range(1, n + 1):
		fact[i] = fact[i - 1] * i % p
	return fact[n] * (modInv(fact[r], p) * modInv(fact[n - r], p)) % p % p

def f(n, q):
	p = 10 ** 9 + 7
	for i in range(q):
		(l, k) = list(map(int, input().split()))
		if l < k:
			print(0)
		else:
			temp = pow(2, n - l, p) * modNcr(l - 1, k - 1, p) % p
			print(temp % (10 ** 9 + 7))
t = int(input())
for i in range(t):
	(n, q) = list(map(int, input().split()))
	f(n, q)


import sys
z = 10 ** 9 + 7
cachencr = {}
cachepow = {}
fact = []
fact.append(1)
for i in range(1, 4000):
	fact.append(i * fact[i - 1] % z)

def factorialMod(n):
	ans = 1
	for i in range(1, n + 1):
		ans = ans * i % z
	return ans % z

def nCr(n, r):
	if r > n:
		return 0
	key = n + r * 4001
	if key in cachencr:
		return cachencr[key]
	else:
		cachencr[key] = fact[n] * pow(fact[r] * fact[n - r], z - 2, z) % z
		return cachencr[key]

def powc(n):
	if n in cachepow:
		return cachepow[n]
	else:
		cachepow[n] = pow(2, n, z)
		return cachepow[n]
for _ in range(0, int(input())):
	(n, q) = list(map(int, input().split()))
	for __ in range(0, q):
		(i, k) = list(map(int, sys.stdin.readline().split()))
		a = nCr(i - 1, k - 1)
		b = powc(n - i)
		print(a * b % z)


z = 10 ** 9 + 7
fact = []
fact.append(1)
for i in range(1, 4000):
	fact.append(i * fact[i - 1] % z)

def factorialMod(n):
	ans = 1
	for i in range(1, n + 1):
		ans = ans * i % z
	return ans % z

def nCr(n, r):
	if r > n:
		return 0
	return fact[n] * pow(fact[r] * fact[n - r], z - 2, z) % z
for _ in range(0, int(input())):
	(n, q) = list(map(int, input().split()))
	for __ in range(0, q):
		(i, k) = list(map(int, input().split()))
		a = nCr(i - 1, k - 1)
		b = pow(2, n - i, z)
		print(a * b % z)


def nCr(n, r):
	if n < r:
		return 0
	M = 10 ** 9 + 7
	ret = fact[n] * pow(fact[r], M - 2, M) * pow(fact[n - r], M - 2, M)
	return ret % M
MOD = 10 ** 9 + 7
fact = [1] * 4001
for i in range(1, 4001):
	fact[i] = fact[i - 1] * i % MOD
for t in range(eval(input())):
	(n, q) = list(map(int, input().split()))
	for qq in range(q):
		(i, k) = list(map(int, input().split()))
		print(nCr(i - 1, k - 1) * pow(2, n - i, MOD) % MOD)