Q=int(input()) N = 4 SIZE0 = 4*N-4 N=N-2 SIZE1 = 4*N-4 N,i,j=map(int, input().split()) # depth position estimate depth = min([min([i, (N-1)-i]), min([j, (N-1)-j])]) # print(depth) cum_size = 0 for d in range(depth): cum_size += 4*N-4 N=N-2 # print(cum_size) import numpy as np tmp = np.zeros((N, N)).astype(int) tmp[0,:] = [n for n in range(N)] tmp[:,N-1] = [n+N-1 for n in range(N)] tmp[N-1,:] = list(reversed([n+2*(N-1) for n in range(N)])) for n in range(N-1): tmp[N-1-n,0] =n+3*(N-1) # print(tmp) print(tmp[j-depth, i-depth] + cum_size)