#include int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(), k = ri(); int64_t sum = (int64_t) (1 + n) * n / 2; int one = n / k; if (sum % k || one == 1) { std::cout << "No" << std::endl; } else if (one % 2 == 0) { std::cout << "Yes" << std::endl; for (int i = 0; i < k; i++) { for (int j = 0; j < one; j++) { if (j & 1) std::cout << j * k + i + 1 << " "; else std::cout << (j + 1) * k - i << " "; } std::cout << std::endl; } } else { std::cout << "Yes" << std::endl; std::vector > res(k); for (int i = 0; i + 3 < one; i++) { if (i & 1) { for (int j = 0; j < k; j++) res[j].push_back(i * k + 1 + j); } else { for (int j = 0; j < k; j++) res[j].push_back((i + 1) * k - j); } } int base = (one - 3) * k + 1; for (int i = 0; i < k; i++) res[i].push_back(base + i * 2 % k); base += k; for (int i = k / 2; i >= 0; i--) res[i].push_back(base++); for (int i = k - 1; i > k / 2; i--) res[i].push_back(base++); for (int i = k - 1; i >= 0; i--) res[i].push_back(base++); for (int i = 0; i < k; i++) { for (int j = 0; j < one; j++) std::cout << res[i][j] << " "; std::cout << std::endl; } } return 0; }