#include #include using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) const int Z = 500001; vector dp[2]; void procdp(int x){ rep(t,2) for(int p = Z/x; p>0; p--) dp[t][p*x] = max(dp[t][p*x],dp[t][p]+1); rep(t,2) for(int p = Z/x; p>0; p--) dp[t][p*x] = max(dp[t][p*x],dp[t^1][p]+1); } vector X; int main(){ rep(t,2) dp[t].assign(Z+1,0); dp[0][1] = 2; dp[1][1] = 1; for(int x=2; x<=Z; x++) procdp(x); X.assign(Z*2+1,0); for(int i=1; i<=Z; i++) X[Z-i] = ((dp[1][i] >= 5) ? 1 : 0); for(int i=1; i<=Z; i++) X[Z+i] = ((dp[0][i] >= 5) ? 1 : 0); rep(i,Z*2) X[i+1] += X[i]; int T; cin >> T; while(T--){ int p,l,r; cin >> p >> l >> r; l--; l -= p; r -= p; int ans = X[r+Z] - X[l+Z]; cout << ans << "\n"; } return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_inst;