def main(): Q = int(input()) for _ in range(Q): N,T = map(int,input().split()) if N == 2: if T%2 == 1: print("No") else: ret = [1,2,T//2] print(*ret) elif N == 3: ret = [1,2,0]; print(*ret) ret = [2,3,0]; print(*ret) ret = [1,3,T]; print(*ret) elif T%N == 0: cost = T//N for i in range(N): for j in range(i+1,N): ret = [i+1,j+1,cost] print(*ret) elif N == 4: if T%2 == 1: print("No") else: for i in range(N): for j in range(i+1,N): if i == 0: ret = [i+1,j+1,0] else: ret = [i+1,j+1,T//2] print(*ret) else: print("No") if __name__ == '__main__': main()