#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); auto f = [](ll N, ll I, ll J) { ll A = min({I, N - 1 - I, J, N - 1 - J}); // sum_{k = 0, 2, 4, ..., 2A} 4(N-K-1) ll T = 4 * (A) * (N - (A)); // 長さ N-2A のboxの中 // 左上の座標は (A, A) ll ans = -1; if(I == A && A <= J && J <= N - A - 1) { ans = T + J - A; } else if(J == N - A - 1 && A <= I && I <= N - A - 1) { ans = T + N - 2 * A - 1 + I - A; } else if(I == N - A - 1 && A <= J && J <= N - A - 1) { ans = T + N - 2 * A - 1 + N - 2 * A - 1 + (N - A - 1 - J); } else { ans = T + N - 2 * A - 1 + N - 2 * A - 1 + N - 2 * A - 1 + (N - A - 1 - I); } return ans; }; int Q; cin >> Q; rep(_,Q) { int N, I, J; cin >> N >> I >> J; cout << f(N, I, J) << "\n"; } }