#include // #include using namespace std; // using namespace atcoder; typedef int64_t lint; #define rep(i, n) for(int i=0; i; using vvi = vector>; template inline void vin(vector& v) { rep(i, v.size()) cin >> v.at(i); } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template inline void drop(T x) { cout << x << endl; exit(0); } template void vout(vector v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; } constexpr lint LINF = LLONG_MAX/2; vector divisor(lint n) { vector v; for (lint i = 1; i*i <= n; i++) { if (n % i == 0) { v.push_back(i); if (i*i != n) v.push_back(n/i); } } sort(v.begin(), v.end()); return v; } int main() { lint N, H; cin >> N >> H; vi v = divisor(N); // vout(v); vvi w1(H, vi(N/H)); vvi w2(H, vi(N/H)); lint a=0, b=0, c=0, x=0, y=0, z=0; rep(i, v.size()-1) { lint ta = a, tb = b, tx = x, ty = y; rep(j, v[i]) { w1[a][b] = v[i]; w2[y][x] = v[i]; a++; if (a%H == 0) { a = 0; b++; } x++; if (x%(N/H) == 0) { x = 0; y++; } } if (tb != b && a != 0) c = 1; if (ty != y && x != 0) z = 1; } if (c+z == 2) drop(-1); if (z == 1) { rep(i, H) { vout(w1[i]); } } else { rep(i, H) { vout(w2[i]); } } }