N, K = map(int, input().split()) shou, amari = divmod(N, K**2) for i in range(1000): if i ** 2 >= amari: M = shou*K + i break ans = [['.'] * M for _ in range(M)] for i in range(shou): for j in range(i*K, i*K+K): for k in range(i*K, i*K+K): ans[j][k] = '#' for i in range(shou*K, M): for j in range(shou*K, M): ans[i][j] = '#' amari -= 1 if amari == 0: break else: continue break print(M) for ans_i in ans: print(''.join(ans_i))