#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(a);i>(b);i--) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; typedef pair P; 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; } templatevoid Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);} const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2; //template end int main(){ int n,k; scanf("%d%d",&n,&k); int m=0,cnt1=0; while(n>=k*k){ n-=k*k; m+=k; cnt1++; } int cnt2=0; while(n>cnt2*cnt2)cnt2++; m+=cnt2; printf("%d\n",m); vector> g(m); rep(i,0,m)g[i].resize(m,'.'); rep(i,0,cnt1){ rep(j,0,k)rep(l,0,k){ g[i*k+j][i*k+l]='#'; } } rep(i,0,n){ int dx=i%cnt2,dy=i/cnt2; g[cnt1*k+dx][cnt1*k+dy]='#'; } cnt1=0; rep(i,0,m)rep(j,0,m)if(g[i][j]=='#')cnt1++; assert(cnt1==k); rep(i,0,m){ rep(j,0,m)cout<