#!/usr/bin/env python3 import sys readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) q = int(readline()) for _ in range(q): n, i, j = map(int, readline().split()) layer = min(i, j, n - 1 - i, n - 1 - j) ans = n * n - (n - layer * 2) * (n - layer * 2) if i == layer: ans += j - layer elif j == n - layer - 1: ans += n - layer * 2 - 1 + i - layer elif i == n - layer - 1: ans += 2 * (n - layer * 2) + (n - layer - 1 - i) else: ans += 3 * (n - layer * 2) + (n - layer - 1 - j) print(ans)