# じゃがいもの皮をむくイメージ # 最初の皮の層は(N-1)*4、次の皮の層は(N-3)*4、、、と続く # (i, j)が与えられたら第何層の何個目かでわかるはず Q = int(input()) for q in range(Q): n, i, j = map(int, input().split()) # 第何層か i_layer = min(i, n-1-i) j_layer = min(j, n-1-j) layer = min(i_layer, j_layer) s = 0 for l in range(layer): s += (n-l*2-1)*4 #print('layer', layer, 's', s) # その中の何番目か、第k層の最初は(k, k) idx_in_layer = 0 if i == layer: idx_in_layer = j-layer elif i == n-1-layer: idx_in_layer = (n-(layer*2+1))*2 + (n-1-layer) - j elif j == n-1-layer: idx_in_layer = (n-(layer*2+1)) + i - layer elif j == layer: idx_in_layer = (n-(layer*2+1))*3 + (n-1-layer) - i #print(i, j, 'layer', layer, 's', s, s+idx_in_layer) print(s+idx_in_layer)