def g(N): 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 T=int(input()) assert 1<=T<=2000,"Tが範囲外(T={})".format(T) X=[0]*T for k in range(T): D,A,B=map(int,input().split()) assert 2<=D<=10**9,"(第{}テストケース)Dが範囲外(D={})".format(k+1,D) assert 0<=A<=B<=10**9,"(第{}テストケース)A,Bが範囲外(A={},B={})".format(k+1,A,B) X[k]=g(B)-g(max(A-1,0)) print("\n".join(map(str,X)))