Q = int(input()) for _ in range(Q): N, I, J = map(int, input().split()) n = min(I, N - 1 - I, J, N - 1 - J) r = N - 2 * n I, J = I - n, J - n s = 4 * n * (N - n) if I == 0: print(s + J) elif J == r - 1: print(s + (r - 1) + I) elif I == r - 1: print(s + (r - 1)*2 + r - 1 - J) else: print(s + (r - 1)*3 + r - 1 - I)