#include #define rep(i,a) for(int i=(int)0;i<(int)a;++i) #define rrep(i,a) for(int i=(int)a-1;i>=0;--i) #define REP(i,a,b) for(int i=(int)a;i<(int)b;++i) #define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i) #define pb push_back #define eb emplace_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() typedef std::vector vi; typedef std::vector> vvi; typedef std::vector vl; typedef std::vector> vvl; #define out(x) cout< inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } ll gcd(ll n, ll m) { ll tmp; while (m!=0) { tmp = n % m; n = m; m = tmp; } return n; } ll lcm(ll n, ll m) { return abs(n) / gcd(n, m)*abs(m);//gl=xy } using namespace std; void solve() { int q; cin >> q; while(q--){ ll n, x, y; cin >> n >> x >> y; ll num = min(min(x, n - 1 - x), min(y, n - 1 - y)); if((y==n-1-num)||(x==num)){ cout << 4 * num * (n - num)+x+y-2*num << "\n"; } else { x = n - 1 - num - x, y = n - 1 - num - y; cout << 4 * num * (n - num)+x+y-2*num+2*(n-1-num) << "\n"; } } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout<