def solve(): g, a, b = map(int, input().split()) if a == 0: if b == 0: print(0) return a = 1 g -= 1 ans = 0 c = (a - 1) % g + 1 d = (b - 1) % g + 1 if d >= c: ans += (d + c) * (d - c + 1) // 2 l = (b - a + 1) - (d - c + 1) l //= g else: ans += (1 + d) * d // 2 ans += (g + c) * (g - c + 1) // 2 l = (b - a + 1) - d - (g - c + 1) l //= g ans += l * (1 + g) * g // 2 print(ans) for _ in range(int(input())): solve()