inputs = []

while true
  h, w = $stdin.readline.split(" ").map {|s| s.to_i }

  if h == 0 && w == 0
    break
  end

  inputs.push([h, w])
end

inputs.each do |h, w|
  (1..h).each_with_index do |y, i|
    if i == 0 || i == h - 1
      puts "#" * w
    else
      print "#", "." * (w - 2), "#", "\n"
    end
  end

  puts
end

