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+=4*N-8*mi-4-y elif y==mi: ans+=x elif x==N-1-mi: ans+=N-2*mi-1+y else: ans+=3*N-6*mi-3-x print(ans)