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