def draw_frame(h, w)
  h.times do |i|
    if i == 0 || i + 1 == h
      puts "#" * w
    else
      puts "#" + "." * (w - 2) + "#"
    end
  end
end

loop do
  h, w = gets.chomp.split(" ").map(&:to_i)
  if h == 0 && w == 0
    break
  else
    draw_frame(h, w)
    print "\n"
  end
end