#include using namespace std; using ll = long long; ll g(ll N, ll D) { ll ans = 0; ll Q, R; if (N == 0) { return 0; } if (N % (D - 1) == 0) { Q = N / (D - 1); R = 0; } else { Q = N / (D - 1) + 1; R = D - 1 - N % (D - 1); } return Q * (D * (D - 1)) / 2 - D * R + (R * (R + 1)) / 2; } ll max(ll a, ll b) { if (a >= b) { return a; } else { return b; } } int main() { ll T; ll D, A, B; cin >> T; for (int i = 0; i < T; i++) { cin >> D >> A >> B; cout << g(B, D) - g(max(A - 1, 0), D) << endl; } return 0; }