#include using namespace std; typedef long long ll; typedef long double ld; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> q; while(q--){ ll n,i,j;cin >> n >> i >> j; ll t=min({i,n+1-i,j,n+1-j}); ll sum=0; ll k=1; while(t>k){ sum+=4*(n-(k-1)*2-1); k++; } if(t==i){ cout << sum+j-1-(k-1) << endl; continue; } sum+=n-2*(k-1)-1; if(t==n+1-j){ cout << sum+i-1-(k-1) << endl; continue; } sum+=n-2*(k-1)-1; if(t==n+1-i){ cout << sum+n-j-(k-1) << endl; continue; } sum+=n-2*(k-1)-1; cout << sum+n-i-(k-1) << endl; } }