def write(h, w)
  h.times do |n|
    if n == 0
      puts '#' * w
      next
    end
    if n == (h - 1)
      puts '#' * w
      next
    end
    puts "##{'.' * (w - 2)}#"
  end
  puts ''
end


def func
  loop do
    h, w = gets.split.map(&:to_i)
    break if [h, w].all? {|n| n == 0}

    write(h, w)
  end
end


func
