Q = int(input()) for _ in range(Q): n, i, j = map(int, input().split()) m = min(n - i - 1, n - j - 1, i, j) ans = n ** 2 - (n - m * 2) ** 2 n -= m * 2 i -= m j -= m if i == 0: ans += j elif j == n - 1: ans += n + i - 1 elif i == n - 1: ans += (n - 1) * 3 - j elif j == 0: ans += (n - 1) * 4 - i print(ans)