Q=int(input()) for q in range(Q): N = 4 SIZE0 = 4*N-4 N=N-2 SIZE1 = 4*N-4 N,i,j=map(int, input().split()) # depth position estimate depth = min([min([i, (N-1)-i]), min([j, (N-1)-j])]) ans = N * N - (N - depth * 2) * (N - depth * 2) + 2 * (N - depth * 2 - 1) dist = (N - depth - 1 - i) + (N - depth - 1 - j) if i <= j: ans -= dist else: ans += dist print(ans)