while n = gets.split.map(& :to_i)
  if n[0] == 0 && n[1] == 0
    break
  end
  n[1].times do
    print "#"
  end
  puts ""
  (n[0] - 2).times do
    print "#"
    (n[1] - 2).times do
      print "." 
    end
    print "#\n"
  end
  n[1].times do
    print "#"
  end
  puts ""
  puts ""
end