#ifdef LOCAL //#define _GLIBCXX_DEBUG #else #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") //#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #endif #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair P; typedef pair Pi; typedef vector Vec; typedef vector Vi; typedef vector Vs; typedef vector Vc; typedef vector

VP; typedef vector VVP; typedef vector VV; typedef vector VVi; typedef vector VVc; typedef vector VVV; typedef vector VVVV; #define MAKEVV(variable, a, ...) VV variable(a, Vec(__VA_ARGS__)) #define MAKEVVc(variable, a, ...) VVc variable(a,Vc(__VA_ARGS__)) #define MAKEVVV(variable, a, b, ...) VVV variable(a, VV(b, Vec(__VA_ARGS__))) #define MAKEVVVV(variable, a, b, c, ...) VVVV variable(a, VVV(b, (VV(c, Vec(__VA_ARGS__))))) #define endl '\n' #define REP(i, a, b) for(ll i=(a); i<(b); i++) #define PER(i, a, b) for(ll i=(a); i>=(b); i--) #define rep(i, n) REP(i, 0, n) #define per(i, n) PER(i, n, 0) const ll INF = 1'000'000'000'000'000'010LL; const ll MOD=998244353; #define Yes(n) cout << ((n) ? "Yes" : "No") << endl; #define YES(n) cout << ((n) ? "YES" : "NO") << endl; #define ALL(v) v.begin(), v.end() #define rALL(v) v.rbegin(), v.rend() #define pb(x) push_back(x) #define mp(a, b) make_pair(a,b) #define Each(a,b) for(auto &a :b) #define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i) #define SUM(a) accumulate(ALL(a),0LL) #ifdef LOCAL #define dbg(x_) cerr << #x_ << ":" << x_ << endl; #define dbgmap(mp) cerr << #mp << ":"<first <<":"<second << endl;} #define dbgset(st) cerr << #st << ":"<bool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (bauto lb(T &X, ll x){return lower_bound(ALL(X),x) - X.begin();} templateauto ub(T &X, ll x){return upper_bound(ALL(X),x) - X.begin();} ll popcnt(ll x){return __builtin_popcount(x);} ll topbit(ll t){return t==0?-1:63-__builtin_clzll(t);} ll floor(ll y,ll x){assert(x != 0);if(x < 0){y *= -1; x *= -1;}if(y < 0){return (y-x+1)/x;}return y/x;}; ll ceil(ll y, ll x){assert(x != 0);if(x < 0){y *= -1; x *= -1;}if(y < 0){return y/x;}return (y+x-1)/x;}; template ostream &operator<<(ostream &s, const pair &p) { return s<<"("< istream &operator>>(istream &i, pair &p) { return i>>p.first>>p.second; } templateistream& operator>>(istream&i,vector&v) {rep(j,v.size())i>>v[j];return i;} // vector template ostream &operator<<(ostream &s, const vector &v) { int len=v.size(); for(int i=0; i ostream &operator<<(ostream &s, const vector > &vv) { s<>n; ll h; cin>>h; if(n % h != 0){ out(-1); return 0; } ll w = n/h; map mpg; mpg[6] = {1,2,3}; mpg[28] = {1,2,4,7,14}; mpg[496] = {1, 2, 4, 8, 16, 31, 62, 124, 248}; mpg[8128] = {1 , 2 , 4 , 8 , 16 , 32 , 64 , 127 , 254 , 508 , 1016 , 2032 , 4064}; Vec v = mpg[n]; bool change = false; if(h * h < n){ change = true; swap(h,w); } VV ans(h, Vec(w)); dbg(mp(h,w)); ll i = 0; ll j = 0; Each(x, v){ if(x < h){ ll tmp = 0; while(tmp < x){ ans[i][j] = x; tmp++; i++; } }else{ if(x == h){ j++; } ll lim = j+x/h; REP(k,j,lim){ rep(l,h){ ans[l][k] = x; } } j += x/h; } } dbg(ans); if(change){ VV ANS(w, Vec(h)); rep(i,h){ rep(j,w){ ANS[j][i] = ans[i][j]; } } rep(i,w){ rep(j,h){ cout<>T; // while(T--) solve(); }