def cost(A,B): if B<=0: return inf else: return max(A-B,0) T=int(input()) X=[0]*T inf=float("inf") for i in range(T): A,B,C=map(int,input().split()) K=0 if A==C: A-=1 K=1 A,C=min(A,C),max(A,C) if A<=0: X[i]=-1 continue if A==B: X[i]=1+K continue if B==C: if A+1==C: X[i]=2+K else: X[i]=1+K continue if B