func_code_string: #include <bits/stdc++.h>   using namespace std;   long long N, M, x, y, K, ml, T, ans;   long long f[1000000], s[1000000];   const long long md = 1e9 + 7;   const long long MAXN = 1e5 + 2;   string in;   int main() {     cin >> N >> K;     f[0] = 1;     for (int i = 1; i <= MAXN; i++) {       f[i] = f[i - 1];       if (i >= K) f[i] = (f[i] % md + f[i - K] % md) % md;     }     s[0] = 0;     for (int i = 1; i <= MAXN; i++) s[i] = (s[i - 1] % md + f[i] % md) % md;     for (int i = 0; i < N; i++) {       cin >> x >> y;       ans = (s[y] - s[x - 1] + md) % md;       cout << ans << endl;     }     return 0;   }   