#include using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair int main() { int q; cin >> q; rep(qi,q) { ll n, i, j; cin >> n >> i >> j; ll r = n; r = min(r, n-1-i); r = min(r, n-1-j); r = min(r, i); r = min(r, j); i -= r, j -= r; ll ans = n*n-(n-r*2)*(n-r*2); ll n2 = n-r*2; if (i == 0) { ans += j; } else if (j == n2-1) { ans += n2+i-1; } else if (i == n2-1) { ans += 3*n2-j-3; } else if (j == 0) { ans += 4*n2-i-5; } cout << ans << endl; } }