n, k = read_line.split.map &.to_i m = n >= k * k ? (n + k - 1)//k : Math.sqrt(n).ceil.to_i ans = Array.new(m) { Array.new(m, '.') } m.times do |i| {k, m}.min.times do |j| if n > 0 ans[i][(i + j) % m] = '#' n -= 1 end end end puts m, ans.map(&.join).join('\n')