import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): Q = int(input()) NIJ = [[int(x) for x in input().split()] for _ in range(Q)] for n, i, j in NIJ: c = 0 for k in range(n // 2 + 1): if i == 0 + k: print(c + j - k) break elif j == n - 1 - k: print(c + n - 2 * k - 1 + i - k) break elif i == n - 1 - k: print(c + 2 * (n - 2 * k) - 2 + (n - j - 1) - k) break elif j == 0 + k or j == n - 1 - k: print(c + 3 * (n - 2 * k) - 3 + (n - i - 1) - k) break else: c += (n - 2 * k) * 4 - 4 continue if __name__ == '__main__': main()