#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); // r(n, d) = 1 + (n - 1 mod d - 1) auto r = [](ll X, ll d) { ll ans = 0; for(ll x = 0; x <= X; x++) ans += 1 + (x - 1) % (d - 1); return ans; }; auto f = [](ll X, ll d) { ll ans = 0; ans += X; ans += ((X - 1) / (d - 1)) * ((d - 2) * (d - 1) / 2); ll r = (X - 1) % (d - 1); ans += r * (r + 1) / 2; return ans; }; int T; cin >> T; rep(_,T) { ll d,A,B; cin >> d >> A >> B; cout << f(B, d) - f(A - 1, d) << "\n"; } return 0; }