Q=int(input()) for i in range(Q): N,T=map(int,input().split()) if (T&1)==0: print('Yes') for j in range(N): for k in range(j+1,N): print(j+1,k+1,(T>>1)*(1 if j==0 else 0)) continue if N==3: print('Yes') print(1,2,T) print(2,3,0) print(1,3,0) continue print('No')