N, K = gets.split.map(&:to_i) s = 1 while s * s < N || s * K < N s += 1 end G = Array.new(s) { Array.new(s, '.') } cy = 0 cx = 0 N.times do if G[cy][cx] == '#' cx += 1 end G[cy][cx] = '#' cy += 1 cx += 1 cy %= s cx %= s end puts s puts G.map { |row| row.join }