#include using namespace std; using ll = long long; constexpr char newl = '\n'; ll calc(ll n, ll d) { if (n <= 0) return 0; ll ans = (d - 1) * d / 2 * (n / (d - 1)); ll rest = n % (d - 1); ans += (rest + 1) * rest / 2; return ans; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int t; cin >> t; for (int loop = 0; loop < t; loop++) { ll d, a, b; cin >> d >> a >> b; cout << calc(b, d) - calc(a - 1, d) << newl; } return 0; }