#include #include #include #include #include template inline bool chmin(T &lhs, const U &rhs) { if (lhs > rhs) { lhs = rhs; return true; } return false; } template inline bool chmax(T &lhs, const U &rhs) { if (lhs < rhs) { lhs = rhs; return true; } return false; } // [l, r) from l to r struct range { struct itr { int i; constexpr itr(int i_): i(i_) { } constexpr void operator ++ () { ++i; } constexpr int operator * () const { return i; } constexpr bool operator != (itr x) const { return i != x.i; } }; const itr l, r; constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { } constexpr itr begin() const { return l; } constexpr itr end() const { return r; } }; // [l, r) from r to l struct revrange { struct itr { int i; constexpr itr(int i_): i(i_) { } constexpr void operator ++ () { --i; } constexpr int operator * () const { return i; } constexpr bool operator != (itr x) const { return i != x.i; } }; const itr l, r; constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { } constexpr itr begin() const { return r; } constexpr itr end() const { return l; } }; int main() { int Q; std::cin >> Q; while (Q--) { long long N, i, j; std::cin >> N >> i >> j; long long stage = std::min({ i, N - i - 1, j, N - j - 1 }); long long ans = N * N - (N - stage) * (N - stage); if (i == stage) { ans += j - stage; } else if (j == N - stage - 1) { ans += (N - 2 * stage - 1); ans += i - stage; } else if (i == N - stage - 1) { ans += (N - 2 * stage - 1) * 2; ans += N - stage - 1 - j; } else { ans += (N - 2 * stage - 1) * 3; ans += N - stage - 1 - i; } std::cout << ans << '\n'; } return 0; }