INF = 10 ** 9 MOD = 10 **9 + 7 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from collections import deque from math import factorial def main(): q = int(input()) for _ in range(q): n,i,j = map(int,input().split()) d = min(i,j,n - 1 - i,n - 1 - j) i -= d j -= d n -= 2*d step = n * n - (n - 2*d) * (n - 2*d) if i == 0: print(step + j) elif j == 0: print(step + 3*(n - 1) + n - 1 - i) elif i == n - 1: print(step + 2*(n - 1) + (n - 1 - j)) elif j == n - 1: print(step + n - 1 + i) if __name__=='__main__': main()