import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Main { public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException { String[] line = stdin.readLine().split(" "); int n = Integer.parseInt(line[0]); int k = Integer.parseInt(line[1]); if (!ok(n, k)) { stdout.println("No"); return; } int m = n / k; List> matrix = new ArrayList<>(); for (int i = 0; i < m; i++) { matrix.add(new ArrayList<>()); } for (int i = 0; i < n; i++) { matrix.get(i / k).add(i + 1); } if (m % 2 == 0) { for (int i = m / 2; i < m; i++) { Collections.reverse(matrix.get(i)); } } else { int x = 0; for (int i = 0; i < m; i++) { List r1 = matrix.get(i).subList(0, x); List r2 = matrix.get(i).subList(x, k); matrix.set(i, new ArrayList<>()); matrix.get(i).addAll(r2); matrix.get(i).addAll(r1); x = (x + 1) % k; } } stdout.println("Yes"); for (int i = 0; i < k; i++) { List ans = new ArrayList<>(); for (int j = 0; j < m; j++) { ans.add(Integer.toString(matrix.get(j).get(i))); } stdout.println(String.join(" ", ans)); } } public boolean ok(long n, long k) { return n != k && (n * (n + 1) / 2) % k == 0; } public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); PrintWriter stdout = new PrintWriter(System.out, false); new Main().solve(stdin, stdout); stdout.flush(); } }