while true 
h,w = gets.split(" ").map(&:to_i)
break if (H == 0 && W == 0) end
 for i in 1..h do
  for j in 1..w do
     if ((j >=2 && j<=W-1) && ( i>=2 && i<=H-1)) then
        print "."
     elsif print "#"
end 
end
puts " "
end