q = int(input()) for _ in range(q): n, i, j = map(int, input().split()) loop = min(i, j, n - 1 - i, n - 1 - j) t = n ** 2 - (n - 2 * loop) ** 2 n -= loop * 2 i -= loop j -= loop if i == 0: print(t + j) elif j == n - 1: print(t + n - 1 + i) elif i == n - 1: print(t + 2 * (n - 1) + (n - 1 - j)) else: print(t + 3 * (n - 1) + (n - 1 - i))