def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 K = int(input[idx]) idx += 1 if K == 1 or K >= N - 1: print("No") return if K == 2: if N < 4: print("No") return edges = [] # Main chain 1-2-3-4 with edges 2, -3, 2 edges.append((1, 2, 2)) edges.append((2, 3, -3)) edges.append((3, 4, 2)) # Remaining nodes are connected to 1 with weight 2 for i in range(5, N+1): edges.append((1, i, 2)) # Check sum total = 2 -3 +2 + 2*(N -4) if total <= 0: print("No") return print("Yes") for u, v, w in edges: print(u, v, w) return # For K >=3 M = N - (K+1) if M * 2 <= K: print("No") return edges = [] # Main chain: K edges, all -1 for i in range(1, K+1): u = i v = i + 1 edges.append((u, v, -1)) # Remaining M nodes connected to 1 for i in range(K+2, N+1): edges.append((1, i, 2)) # Check sum sum_main = -K sum_leaves = 2 * M total = sum_main + sum_leaves if total <= 0: print("No") return print("Yes") for u, v, w in edges: print(u, v, w) if __name__ == "__main__": main()