def draw
   mp=gets.split(' ').map(&:to_i)
   if mp[0]==0 && mp[1]==0 then return -1 end
   for y in 1..mp[0] do
      for x in 1..mp[1] do
         if x==1 || x==mp[1] || y==1 || y==mp[0] then
            print "#"
         else
            print "."
         end
      end
      print "\n"
   end
   print "\n"
   return 0
end

ret=draw
until ret==-1 do
    ret=draw
end