#include <bit>
#include <iostream>
#include <vector>

int main() {
  unsigned N, H;
  std::cin >> N >> H;
  const auto W = N / H;

  std::vector res(H, std::vector(W, 0u));

  for (auto i = 1u, c = 0u; i < N; ++i)
    if (N % i == 0)
      for (auto j = 0u; j < i; ++j, ++c) (not std::has_single_bit(W) ? res[c / W][c % W] : res[c % H][c / H]) = i;

  for (const auto& row : res) {
    for (const auto& e : row) std::cout << e << ' ';
    std::cout << '\n';
  }
}