import math N, K = map(int,input().split()) b = N//(K*K) r = N%(K*K) G = [["." for k in range(10)] for l in range(10)] for p in range(b): for x in range(K): for y in range(K): G[K*p+x][K*p+y] = "#" if r == 0: print(K*b) for k in range(K*b): print("".join(G[k][:K*b])) else: s = math.ceil(math.sqrt(r)) c = 0 for p in range(b,10000000): for x in range(s): for y in range(s): G[K*p+x][K*p+y] = "#" c += 1 if c == r: print(K*b+s) for k in range(K*b+s): print("".join(G[k][:K*b+s])) exit(0)