#include #include #include #include #include #include #include #include #include #include #define mkp make_pair #define mkt make_tuple #define rep(i,n) for(int i = 0; i < (n); ++i) #define all(v) v.begin(),v.end() using namespace std; typedef long long ll; const ll MOD=1e9+7; template void chmin(T &a,const T &b){if(a>b) a=b;} template void chmax(T &a,const T &b){if(a0){ res+=x%d; x/=d; } return res; } void solve(){ ll D,A,B; cin>>D>>A>>B; auto calc = [&](ll L){ if(L<=0) return 0ll; ll q=L/(D-1); ll rest=L%(D-1); ll res=q*(D-1)*(D)/2; if(rest) res+=(rest)*(rest+1)/2; return res; }; ll ans=calc(B)-calc(A-1); cout<>T; rep(i,T) solve(); return 0; }