def rec(h,w)
  h.times do |x|
    w.times do |y|
      if x == 0 || x == h - 1 || y == 0 || y == w - 1
        print "#"
      else
        print "."
      end
    end
    print "\n"
  end
end

while true
  h, w = gets.chomp.split.map(&:to_i)
  break if w == 0 && h == 0
  rec(h, w)
  puts ""
end

