t = int(input()) def solve(n, d): if n <= 0: return 0 val = (d - 1) * d // 2 q = n // (d - 1) r = n - (d - 1) * q return val * q + r * (r + 1) // 2 for _ in range(t): d, a, b = map(int, input().split()) print(solve(b, d) - solve(a - 1, d))