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