Q = int(input()) for _ in range(Q): N,i,j = map(int,input().split()) if i%2==0: print(N*i+j) else: print(N*i+N-j-1)