t = int(input()) def solve(n, d): one_cycle = (d - 1) * d // 2 m = n // (d - 1) n -= (d - 1) * m return one_cycle * m + n * (n + 1) // 2 for _ in range(t): d, a, b = map(int, input().split()) print(solve(b, d) - solve(a - 1, d) * (a != 0))