while true
  rect = gets.split.map(&:to_i)

  if rect[0] == 0 && rect[1] == 0
    break
  end

  puts '#'*rect[1]
  (rect[0]-2).times do
    puts '#'+'.'*(rect[1]-2)+'#'
  end
  puts '#'*rect[1]
  puts "\n"
end

