#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) n, k = LI() if (n-1) % k == 0: print("No") else: print("Yes") a = (n - 1) // k b = a + 1 for x in range(n+1): for y in range(x+1, n+1): if -a*y + b*x > 0: break else: continue break for i in range(1, n): if i % k == 0: print(i, i+1, -y) elif i % k == 1: print(i, i+1, x) else: print(i, i+1, 0)