#include <bits/stdc++.h>
const long long MaxN = 1050;
const long long p = 1e9 + 7;
template <class t>
inline void read(t &s) {
  s = 0;
  register long long f = 1;
  register char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
  s *= f;
  return;
}
template <class t, class... A>
inline void read(t &x, A &...a) {
  read(x);
  read(a...);
}
template <class t>
inline void write(t x) {
  if (x < 0) putchar('-'), x = -x;
  long long buf[21], top = 0;
  while (x) buf[++top] = x % 10, x /= 10;
  if (!top) buf[++top] = 0;
  while (top) putchar(buf[top--] ^ '0');
  return;
}
inline void setIn(std::string s) {
  freopen(s.c_str(), "r", stdin);
  return;
}
inline void setOut(std::string s) {
  freopen(s.c_str(), "w", stdout);
  return;
}
inline void setIO(std::string s = "") {
  setIn(s + ".in");
  setOut(s + ".out");
  return;
}
template <class t>
inline bool checkmin(t &x, t y) {
  if (x > y) {
    x = y;
    return 1;
  }
  return 0;
}
template <class t>
inline bool checkmax(t &x, t y) {
  if (x < y) {
    x = y;
    return 1;
  }
  return 0;
}
inline long long lowbit(long long x) { return x & (-x); }
long long fac[MaxN], inv[MaxN], f[60][MaxN];
inline long long fpow(long long a, long long b) {
  register long long res = 1;
  for (; b; b >>= 1, a = a * a % p)
    if (b & 1) res = res * a % p;
  return res;
}
inline long long C(long long n, long long m) {
  if (n < m) return 0;
  return fac[n] * inv[m] % p * inv[n - m] % p;
}
signed main(void) {
  fac[0] = 1;
  for (long long i = 1; i < MaxN; ++i) fac[i] = fac[i - 1] * i % p;
  inv[MaxN - 1] = fpow(fac[MaxN - 1], p - 2);
  for (long long i = MaxN - 2; ~i; --i) inv[i] = inv[i + 1] * (i + 1) % p;
  f[0][0] = 1;
  for (long long i = 1; i < 60; ++i)
    for (long long j = i; j < MaxN; ++j)
      (f[i][j] += f[i][j - i]) %= p, (f[i][j] += f[i - 1][j - i]) %= p;
  long long t, n, k;
  read(t);
  while (t--) {
    read(n, k);
    if (k >= 60) {
      std::puts("0");
      continue;
    }
    register long long ans = 0;
    for (long long i = 1; i <= n; ++i)
      (ans += f[k][i] * C(n - i + k, k) % p * fac[k] % p) %= p;
    write(ans), std::puts("");
  }
  return 0;
}

### Prompt

Your challenge is to write a cpp solution to the following problem:

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.

### Response

```cpp
#include <bits/stdc++.h>
const long long MaxN = 1050;
const long long p = 1e9 + 7;
template <class t>
inline void read(t &s) {
  s = 0;
  register long long f = 1;
  register char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
  s *= f;
  return;
}
template <class t, class... A>
inline void read(t &x, A &...a) {
  read(x);
  read(a...);
}
template <class t>
inline void write(t x) {
  if (x < 0) putchar('-'), x = -x;
  long long buf[21], top = 0;
  while (x) buf[++top] = x % 10, x /= 10;
  if (!top) buf[++top] = 0;
  while (top) putchar(buf[top--] ^ '0');
  return;
}
inline void setIn(std::string s) {
  freopen(s.c_str(), "r", stdin);
  return;
}
inline void setOut(std::string s) {
  freopen(s.c_str(), "w", stdout);
  return;
}
inline void setIO(std::string s = "") {
  setIn(s + ".in");
  setOut(s + ".out");
  return;
}
template <class t>
inline bool checkmin(t &x, t y) {
  if (x > y) {
    x = y;
    return 1;
  }
  return 0;
}
template <class t>
inline bool checkmax(t &x, t y) {
  if (x < y) {
    x = y;
    return 1;
  }
  return 0;
}
inline long long lowbit(long long x) { return x & (-x); }
long long fac[MaxN], inv[MaxN], f[60][MaxN];
inline long long fpow(long long a, long long b) {
  register long long res = 1;
  for (; b; b >>= 1, a = a * a % p)
    if (b & 1) res = res * a % p;
  return res;
}
inline long long C(long long n, long long m) {
  if (n < m) return 0;
  return fac[n] * inv[m] % p * inv[n - m] % p;
}
signed main(void) {
  fac[0] = 1;
  for (long long i = 1; i < MaxN; ++i) fac[i] = fac[i - 1] * i % p;
  inv[MaxN - 1] = fpow(fac[MaxN - 1], p - 2);
  for (long long i = MaxN - 2; ~i; --i) inv[i] = inv[i + 1] * (i + 1) % p;
  f[0][0] = 1;
  for (long long i = 1; i < 60; ++i)
    for (long long j = i; j < MaxN; ++j)
      (f[i][j] += f[i][j - i]) %= p, (f[i][j] += f[i - 1][j - i]) %= p;
  long long t, n, k;
  read(t);
  while (t--) {
    read(n, k);
    if (k >= 60) {
      std::puts("0");
      continue;
    }
    register long long ans = 0;
    for (long long i = 1; i <= n; ++i)
      (ans += f[k][i] * C(n - i + k, k) % p * fac[k] % p) %= p;
    write(ans), std::puts("");
  }
  return 0;
}

```