import java.io.*; import java.util.*; public class Main_yukicoder883 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); int k = sc.nextInt(); int nn = n / (k * k); int r = n - nn * (k * k); int rr = (int)Math.sqrt(r); if (r > rr * rr) { rr++; } int m = nn * k + rr; char[][] a = new char[m][m]; for (int i = 0; i < m; i++) { Arrays.fill(a[i], '.'); } for (int i = 0; i < nn; i++) { int xx = i * k; int yy = i * k; for (int j = 0; j < k; j++) { for (int jj = 0; jj < k; jj++) { a[xx + j][yy + jj] = '#'; } } } int xx = nn * k; int yy = nn * k; int cnt = 0; out: for (int j = 0; j < rr; j++) { for (int jj = 0; jj < rr; jj++) { a[xx + j][yy + jj] = '#'; cnt++; if (cnt >= r) { break out; } } } pr.println(m); for (int i = 0; i < m; i++) { pr.println(a[i]); } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }