#pragma GCC optimize("O3") #include #define ll long long #define rep(i,n) for(ll i=0;i<(n);i++) #define pll pair #define pq priority_queue #define pb push_back #define eb emplace_back #define fi first #define se second #define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define lb(c,x) distance(c.begin(),lower_bound(all(c),x)) #define ub(c,x) distance(c.begin(),upper_bound(all(c),x)) using namespace std; template inline bool chmax(T& a,T b){if(a inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} const ll INF=1e9+7; int main() { ios; ll q; cin >> q; while(q--){ ll n,i,j; cin>> n >> i >> j; vector a; ll m=n-1; while(m>0){ a.push_back(4*m); m-=2; } if(i<=j && j<=n-1-i){ //i週目 ll cnt=min(i,n-1-i); ll sum=0; rep(p,cnt){ sum+=a[p]; } if(i==cnt){ cout << sum+abs(j-cnt) << endl; } else{ cout << sum+abs(n-1-cnt-j)+2*(n-1-2*cnt) << endl; } } else{ //j週目 ll cnt=min(j,n-1-j); ll sum=0; rep(p,cnt){ sum+=a[p]; } if(j==cnt){ cout << sum+3*(n-1-2*cnt)+abs(n-1-cnt-i) << endl; } else{ cout << sum+(n-1-2*cnt)+abs(i-cnt) << endl; } } } return 0; }