while true

 h,w = gets.split(' ').collect{|n|n.to_i}
 h.times do |hc|
  w.times do |wc|
   if wc==0 || wc==w-1
    print '#' 
    next
   end
   if hc==0 || hc==h-1
    print '#'
   else
    print '.'
   end
   puts
  end
 end
end