#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<; using vi = vector; using vll = vector; char A[1010][1010]; void solve() { MEM(A, '.'); int N, K; cin >> N >> K; int x = 0, mi = INT_MAX, R = 0; for (int i = 1; i <= K; ++i) { int q = N / (i*i); int r2 = N % (i*i); int r = 1; while (r*r < r2)++r; if (i*q + r < mi) { x = i; R = r; mi = i * q + r; } } int M = 0; while (N > 0) { if (N < x*x) { [&] { rep(i, R)rep(j, R) { A[M + i][M + j] = '#'; if (!--N)return; } }(); M += R; } else { rep(i, x)rep(j, x)A[M + i][M + j] = '#'; N -= x * x; M += x; } } cout << M << endl; rep(i, M) { rep(j, M)cout << A[i][j]; cout << endl; } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }