#include using namespace std; void ans(long long a) { cout << a << "\n"; } void solve() { long long n, i, j; cin >> n >> i >> j; i++, j++; long long m = min(min(i, n-i+1), min(j, n-j+1)); long long x = (m-1) * 4 * (n-1) - 4 * (m-1) * (m-2); long long xc = m, yc = m; if (i == xc) return ans(x + j - yc); x += n - 1 - 2 * (m - 1), yc = n - m + 1; if (j == yc) return ans(x + i - xc); x += n - 1 - 2 * (m - 1), xc = n - m + 1; if (i == xc) return ans(x + yc - j); x += n - 1 - 2 * (m - 1), yc = m; return ans(x + xc - i); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int q; cin >> q; while (q--) solve(); return 0; }