/* ---------- STL Libraries ---------- */ // IO library #include #include #include #include #include // algorithm library #include #include #include #include #include #include // container library #include #include #include #include #include #include #include #include #include #include #include // type #include #include /* ---------- Namespace ---------- */ using namespace std; /* ---------- Type ---------- */ using ll = long long; #define int ll template using MaxHeap = priority_queue; template using MinHeap = priority_queue, greater>; #define P pair /* ---------- Constants */ const double PI = 3.141592653589793238462643383279; const ll MOD = 1e9 + 7; const int INF = 1LL << 55; /* ---------- Functions */ template bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } /* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */ signed main() { cin.sync_with_stdio(false); cin.tie(0); cout.tie(0); int Q; cin >> Q; for (int q = 0; q < Q; q++) { int N, I, J; cin >> N >> I >> J; int m = min({J, N-J-1, I, N-I-1}); int around= 2 * N * (N-1) - 2 * (N-m) * (N-m-1); int add; if (I == m) { add = J-m+1; } else if (N-J-1 == m) { add = (N-2*m-1) + (I+1-m); } else if (N-I-1 == m) { add = (2*(N-2*m)-2) + (N+J-m); } else { add = (3*(N-2*m)-3) + (N-I-m); } cout << around + add - 1 << endl; } return 0; }