#include <bits/stdc++.h>
using namespace std;
int f[100000 + 1];
int main() {
  int t, k, i;
  cin >> t >> k;
  f[0] = 1;
  for (i = 1; i <= 100000; i++)
    f[i] = (f[i - 1] + (i >= k ? f[i - k] : 0)) % 1000000007;
  for (i = 1; i <= 100000; i++) f[i] = (f[i - 1] + f[i]) % 1000000007;
  while (t--) {
    cin >> i >> k;
    cout << (f[k] - f[i - 1] + 1000000007) % 1000000007 << endl;
  }
}
