#include #include #include #include using namespace std; #define rep(i,n) for(int i=0; i<(int)(n); i++) vector> solve(int n, int h){ vector ansFlat(n); int p1 = 0, p2 = n; for(int d=1; n%d==0; d*=2){ int D = n / d; if(d != 1) rep(i,D) ansFlat[p1++] = D; rep(i,d) ansFlat[--p2] = d; } vector> ans(h, vector(n/h)); rep(y,h) rep(x,n/h) ans[y][x] = ansFlat[y*(n/h)+x]; return ans; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; int H; cin >> H; int W = N / H; vector> ans; if(H == (H & -H)){ ans = solve(N, H); } else{ vector> buf = solve(N, W); ans.assign(H, vector(W)); rep(y,H) rep(x,W) ans[y][x] = buf[x][y]; } rep(y,H){ rep(x,W){ if(x) cout << ' '; cout << ans[y][x]; } cout << '\n'; } return 0; }