import sys N, K = map(int, input().split()) if N * (N + 1) // 2 % K != 0: print('No') sys.exit() if N // K % 2 == 1 and (N // K) % K == 0: print('Yes') for i in range(K): a = [] for j in range(N // K): a.append(K * j + (i + j) % K + 1) print(*a) elif N // K % 2 == 0: print('Yes') a = [] for i in range(N // 2): a.append(i) a.append(N - 1 - i) for i in range(K): b = [] for j in range(N // K): b.append(a[i * N // K + j] + 1) print(*b) else: print('No')