#include using namespace std; using lint = long long; const lint inf = 1LL << 60; const lint mod = 1000000007; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); lint q; cin >> q; vector n(q), x(q), y(q); for (int i = 0; i < q; ++i) { cin >> n[i] >> x[i] >> y[i]; x[i]--, y[i]--; } for (int i = 0; i < q; ++i) { lint dist = min({x[i], n[i] - 1 - x[i], y[i], n[i] - 1 - y[i]}); lint ret = (n[i] * 4 - 4 + (n[i] - 2 * (dist - 1)) * 4 - 4) * dist / 2; if (dist == x[i]) { ret += y[i] - dist; } else if (dist == n[i] - 1 - y[i]) { ret += n[i] - dist * 2 - 1; ret += x[i] - dist; } else if (dist == n[i] - 1 - x[i]) { ret += (n[i] - dist * 2) * 2 - 2; ret += n[i] - 1 - dist - y[i]; } else { ret += (n[i] - dist * 2) * 3 - 3; ret += n[i] - 1 - dist - x[i]; } cout << ret << "\n"; } return 0; }