#include int ri() { int n; scanf("%d", &n); return n; } int main() { int q = ri(); for (int i = 0; i < q; i++) { int n = ri(); int x = ri(); int y = ri(); int times = std::min({x, n - 1 - x, y, n - 1 - y}); int64_t res = (int64_t) (n - 1) * 4 * times; res -= (int64_t) times * (times - 1) * 4; if (x == times) res += y - times; else if (n - 1 - y == times) res += n - 1 - 2 * times + (x - times); else if (n - 1 - x == times) res += (int64_t) (n - 1 - 2 * times) * 2 + (n - 1 - times - y); else if (y == times) res += (int64_t) (n - 1 - 2 * times) * 3 + (n - 1 - times - x); printf("%" PRId64 "\n", res); } return 0; }