Q=int(input()) for _ in range(Q): N,T=map(int,input().split()) if T%2==1: print("No") continue print("Yes") for i in range(1,N+1): for j in range(i+1,N+1): if i==1: print(i,j,T//2) else: print(i,j,0)