#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) using ll = long long; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; struct edge{int to;ll cap;int rev;}; struct Dinic{ int n; vector> v; vector dist,iter; Dinic(int sz):n(sz),v(sz),dist(sz),iter(sz){} void addedge(int from,int to,ll cap){ int x=v[to].size(),y=v[from].size(); v[from].push_back({to,cap,x}); v[to].push_back({from,0,y}); } void bfs(int s){ fill(dist.begin(),dist.end(),-1); queue q; dist[s]=0; q.push(s); while(q.size()){ int x=q.front();q.pop(); rep(i,v[x].size()){ edge &e=v[x][i]; if(e.cap>0&&dist[e.to]<0){ dist[e.to]=dist[x]+1; q.push(e.to); } } } } ll dfs(int x,int t,ll f){ if(x==t)return f; for(int& i=iter[x];i<(int)v[x].size();++i){ edge& e=v[x][i]; if(e.cap>0&&dist[x]0){ e.cap-=d; v[e.to][e.rev].cap+=d; return d; } } } return 0; } ll max_flow(int s,int t){ ll flow=0; while(1){ bfs(s); if(dist[t]<0)return flow; fill(iter.begin(),iter.end(),0); ll f; while((f=dfs(s,t,1LL<<62))>0)flow+=f; } } }; int main(){ int n,k; cin>>n>>k; int ans = (n+k-1)/k; Dinic dn(2*ans+3); rep(i,ans){ dn.addedge(2*ans,i,k); dn.addedge(ans+i,2*ans+1,k); } rep(i,ans)rep(j,ans){ dn.addedge(i,j+ans,1); } dn.addedge(2*ans+2,2*ans,n); int ret = dn.max_flow(2*ans+2, 2*ans+1); assert(ret==n); cout<> res(ans,vector(ans,0)); rep(i,ans){ for(auto to : dn.v[i]){ if(ans<=to.to&&to.to<2*ans&&to.cap==0){ res[i][to.to-ans]=1; } } } rep(i,ans){ rep(j,ans)cout<<(res[i][j]?'#':'.'); cout<