The sequence of integer pairs (a1, b1), (a2, b2), ..., (ak, bk) is beautiful, if the following statements are fulfilled: 

  * 1 ≤ a1 ≤ b1 < a2 ≤ b2 < ... < ak ≤ bk ≤ n, where n is a given positive integer; 
  * all numbers b1 - a1, b2 - a2, ..., bk - ak are distinct. 



For the given number n find the number of beautiful sequences of length k. As the answer can be rather large, print the remainder after dividing it by 1000000007 (109 + 7).

Input

The first line contains integer t (1 ≤ t ≤ 2·105) — the number of the test data.

Each of the next t lines contains two integers n and k (1 ≤ k ≤ n ≤ 1000).

Output

For each test from the input print the answer to the problem modulo 1000000007 (109 + 7). Print the answers to the tests in the order in which the tests are given in the input.

Examples

Input

6
1 1
2 1
2 2
3 1
3 2
3 3


Output

1
3
0
6
2
0

Note

In the first test sample there is exactly one beautiful sequence: (1, 1).

In the second test sample, the following sequences are beautiful: 

  * (1, 1); 
  * (1, 2); 
  * (2, 2). 



In the fourth test sample, the following sequences are beautiful: 

  * (1, 1); 
  * (1, 2); 
  * (1, 3); 
  * (2, 2); 
  * (2, 3); 
  * (3, 3). 



In the fifth test sample, the following sequences are beautiful: 

  * (1, 1), (2, 3); 
  * (1, 2), (3, 3). 



In the third and sixth samples, there are no beautiful sequences.
// practice with rainboy
import java.io.*;
import java.util.*;

public class CF403D extends PrintWriter {
	CF403D() { super(System.out); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF403D o = new CF403D(); o.main(); o.flush();
	}

	static final int N = 1000, K = 44, MD = 1000000007;
	void main() {
		int[][] dp = new int[K + 1][N + 1];
		dp[0][0] = 1;
		for (int k = 1; k <= K; k++)
			for (int n = 1; n <= N; n++) {
				int x = 0;
				for (int a = 1, m; (m = n - a * k) >= 0; a++)
					x = (x + dp[k - 1][m]) % MD;
				dp[k][n] = x;
			}
		int[] ff = new int[K + 1];
		for (int k = 0, f = 1; k <= K; k++) {
			ff[k] = f;
			f = (int) ((long) f * (k + 1) % MD);
		}
		int[][] ch = new int[N + 1][K + 1];
		ch[0][0] = 1;
		for (int n = 1; n <= N; n++) {
			ch[n][0] = 1;
			for (int k = 1; k <= K; k++)
				ch[n][k] = (ch[n - 1][k - 1] + ch[n - 1][k]) % MD;
		}
		int t = sc.nextInt();
		while (t-- > 0) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			long ans = 0;
			if (k <= K)
				for (int l = k; l <= n; l++)
					ans = (ans + (long) dp[k][l] * ff[k] % MD * ch[n - l + k][k]) % MD;
			println(ans);
		}
	}
}
