#!/usr/bin/env python3 import sys readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) q = int(readline()) def f(n, i, j): 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 - 1) + (n - layer - 1 - j) else: ans += 3 * (n - layer * 2 - 1) + (n - layer - 1 - i) return ans for _ in range(q): n, i, j = map(int, readline().split()) print(f(n, i, j))