Q=int(input()) for q in range(Q): N,x,y=map(int,input().split()) mi=min(N-1-x,N-1-y,x,y) ans=4*(N*mi-mi*mi) if x==mi: ans+=y elif y==N-1-mi: ans+=N-2*mi-1+x elif x==N-1-mi: ans+=3*N-6*mi-3-y else: ans+=4*N-8*mi-4-x print(ans)