while true do
  input = STDIN.gets
  h_w = input.split(" ")
  h = h_w[0].to_i
  w = h_w[1].to_i
  if (h == 0) && (w == 0)
    break
  end
  for i in 1 .. h do
    for j in 1 .. w do
      if i == 1 || i == h || j == 1 || j == w then
        print "#"
      else
        print "."
      end
    end
    print "\n"
  end
  print "\n"
end