mod = 1000000007 eps = 10 ** -9 def main(): import sys input = sys.stdin.buffer.readline for _ in range(int(input())): N, i, j = map(int, input().split()) ii = N - i - 1 jj = N - j - 1 i0 = min(i, j, ii, jj) a = 4 * (N - i0) * i0 if i0 == i: ans = a + j - i0 elif i0 == jj: a += N - 2 * i0 - 1 ans = a + i - i0 elif i0 == ii: a += (N - 2 * i0 - 1) * 2 ans = a + N - i0 - j - 1 else: a += (N - 2 * i0 - 1) * 3 ans = a + N - i0 - i - 2 print(ans) if __name__ == '__main__': main()