T = int(input()) for _ in range(T): A, B, C = map(int, input().split()) if len(set([A, B, C]))==3 and (B==max(A, B, C) or B==min(A, B, C)): print(0) continue if (A>B and B>C) or (A>B and B==C): A, C = C, A if A