#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; ll MOD = 1000000007; typedef pair P; string grid[1010][1010]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; if (n <= k * k) { ll ans = 1, t = 1; for (int i = 1; i < k + 1; i++) { if (i * i >= n) { ans = i; break; } } cout << ans << endl; ll cnt = 0; for (int i = 0; i < ans; i++) { for (int j = 0; j < ans; j++) { if (cnt < n) { cout << "#"; } else { cout << "."; } cnt++; } cout << endl; } } else { int t = k * k, ans = k; while (true) { ans++; if (n - t < k) { break; } t += k; } if (n - t == 1) { ans += 1; } else if (n - t == 2) { ans += 2; } else if (n - t >= 3) { ans += 3; } cout << ans << endl; ll cnt = 0; for (int i = 0; i < ans; i++) { for (int j = 0; j < ans; j++) { grid[i][j] = "."; } } for (int i = 0; i < ans; i = i + k) { for (int a = i; a < k + i; a++) { for (int b = i; b < k + i; b++) { if (cnt < n) { grid[a][b] = "#"; } cnt++; } } } for (int i = 0; i < ans; i++) { for (int j = 0; j < ans; j++) { cout << grid[i][j]; } cout << endl; } } }