for _ in range(int(input())): a, b, c = map(int, input().split()) ans = 0 if a < c: a, c = c, a elif a == c: ans = 1 c -= 1 if c < 1: ans = -1 if ans != -1 and a >= b >= c: ans_a = a-b + 1 + (1 if b-1==c else 0) if a - ans_a < 1: ans_a = -1 ans_b = b-c + 1 if b - ans_b < 1: ans_b = -1 if ans_a == -1 and ans_b == -1: ans = -1 elif ans_a != -1 and ans_b != -1: ans += min(ans_a, ans_b) else: ans += max(ans_a, ans_b) print(ans)