loop do

  num = gets.split(" ")
  h = num[0].to_i
  w = num[1].to_i

  if h == 0 && w == 0 then
    break
  end

  for i in 0..w-1
    print "#"  
  end

  print "\n"

  for i in 0..h-3
   print "#"  
    for j in 0..w-3
      print "."
    end
   puts "#"
  end  

  for i in 0..w-1
    print "#"  
  end

  print "\n"

  print "\n"

end