h,w = gets.split.map {|n| n.to_i}
until h == 0 && w == 0
  for i in 1..h
    for j in 1..w
      if i == 1 || i == h || j == 1 || j == w
        print "#"
      else
        print "."
      end
    end
    print "\n"
  end
  print "\n"
  h,w = gets.split.map {|n| n.to_i}
end