Problem: <image>

To monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:

Initially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, with a uniform distribution, picks a light that is turned off and turns it on, telling William which cryptocurrency he should invest in. After this iteration if any k consecutive lights contain more than one turned on light, then the device finishes working.

William doesn't like uncertainty, so he wants you to calculate the expected value of the number of lights that are turned on in the device after it finishes working.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10). Description of the test cases follows.

The only line for each test case contains two integers n and k (2 ≤ k ≤ n ≤ 10^5), which are the total number of lights and the length of subsegment of lights that are being checked, respectively.

Output

For each test case print the answer, modulo 10^9+7. 

Formally, let M = 10^9+7. It can be shown that the answer can be expressed as an irreducible fraction p/q, where p and q are integers and q not ≡ 0 \pmod{M}. Output the integer equal to p ⋅ q^{-1} mod M. In other words, output such an integer x that 0 ≤ x < M and x ⋅ q ≡ p \pmod{M}.

Example

Input


3
3 2
15 2
40 15


Output


333333338
141946947
329622137

Note

Explanation of the first sample test case:

Let's write out all possible sequences of light toggles, which will make the device complete its operation:

  1. (1, 2) — 2 lights are turned on 
  2. (1, 3, 2) — 3 lights are turned on 
  3. (2, 1) — 2 lights are turned on 
  4. (2, 3) — 2 lights are turned on 
  5. (3, 2) — 2 lights are turned on 
  6. (3, 1, 2) — 3 lights are turned on 



Then the final expected value will be equal to 2/6 + 3/6 + 2/6 + 2/6 + 2/6 + 3/6 = 14/6 = 7/3. 

Then the required output will be 333333338, since 333333338 ⋅ 3 ≡ 7 \pmod{10^9+7}.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

using namespace std;
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define debug(a) cerr << #a << ": " << (a) << '\n';
#define debug_arr(a, n) { cerr << #a << " "; rep(i, 0, n) cerr << a[i] << " \n"[(i + 1) == n]; }
#define debug_two(a, b) cerr << #a << ": " << (a) << ", " << #b << ": " << (b) << '\n';

template <typename num_t>
inline void add_mod(num_t& a, const long long& b, const int& m) { a = (a + b) % m; if (a < 0) a += m; }
template <typename num_t>
inline bool update_max(num_t& a, const num_t& b) { return a < b ? a = b, true : false; }
template <typename num_t>
inline bool update_min(num_t& a, const num_t& b) { return a > b ? a = b, true : false; }
template <typename num_t>
num_t gcd(num_t lhs, num_t rhs) { return !lhs ? rhs : gcd(rhs % lhs, lhs); }
template <typename num_t>
num_t pw(num_t n, num_t k, num_t mod) {
  num_t res = 1; for (; k > 0; k >>= 1) { if (k & 1) res = 1ll * res * n % mod; n = 1ll * n * n % mod; } return res;
}

typedef long long int64;
const int mod = 1000000000 + 7;

struct InverseModule {
  static const int MAX_N = 1e6 + 7;

  int fact[MAX_N];
  int inv_fact[MAX_N];
	int mod = 0;

  InverseModule(int mod) {
		this->mod = mod;
    fact[0] = 1;
    for (int i = 1; i < MAX_N; ++i) {
      fact[i] = (long long) fact[i - 1] * i % this->mod;
    }

    inv_fact[MAX_N - 1] = inverse(fact[MAX_N - 1], this->mod);
    for (int i = MAX_N - 2; i >= 0; --i) {
      inv_fact[i] = (long long) inv_fact[i + 1] * (i + 1) % this->mod;
    }
  }

  int inverse(int x, int mod) {
    int r = mod, newr = x;
    int t = 0, newt = 1;
    while (newr > 0){
      int q = r / newr;
      int tmp = newr; newr = r % newr; r = tmp;
      tmp = newt; newt = t - q * newt; t = tmp;
    }
    if (t < 0) t += mod;
    return t;
  }

  int choose(int n, int k) {
    return (int64) fact[n] * inv_fact[n - k] % this->mod * inv_fact[k] % this->mod;
  }

  int perm(int n, int k) {
    return (int64) fact[n] * inv_fact[n - k] % this->mod;
  }

  pair<int, int> extended_euclid(int a, int b) {
    int s0 = 1, t0 = 0;
    int s1 = 0, t1 = 1;
    while (b > 0) {
      int q = a / b;
      int tmp = 0;
      tmp = s1; s1 = s0 - q * s1; s0 = tmp;
      tmp = t1; t1 = t0 - q * t1; t0 = tmp;
      tmp = b; b = a - q * b; a = tmp;
    }
    return { s0, t0 };
  }
};

auto inv = InverseModule(mod);

void solve() {
  int n, k;
  cin >> n >> k;
  int64 total_ways = 0;
  int64 total_steps = 0;

  auto count_ways = [&](int step) -> int64 {
    int64 remain = n - 1ll * (step - 1) * (k - 1) - step;
    if (remain < 0) return 0;
    return 1ll * inv.fact[remain + step] * inv.inv_fact[remain] % mod;
  };

  int64 ans = 0;
  for (int step = n; step >= 2; --step) {
    auto cur_ways = count_ways(step);
    int64 ways = count_ways(step - 1) * (n - step + 1) - cur_ways;
    add_mod(ways, 0, mod);

    add_mod(ans, ways * step % mod * inv.fact[n - step], mod);

    // add_mod(total_ways, ways, mod);
    // add_mod(total_steps, ways * step, mod);
  }

  cout << ans * inv.inv_fact[n] % mod << '\n';
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
  freopen("in.txt", "r", stdin);
#endif
  const bool multiple_test = true;
  int test = 1;
  if (multiple_test)
    cin >> test;

  for(int i = 0; i < test; ++i) {
    //printf("Case #%d: ", i + 1);
    solve();
  }
#ifdef _LOCAL_
  cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}