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