while true
  h,w = gets.split.map(&:to_i)
  if h == 0 && w == 0 then break end
  t = w-2
  h.times do |i|
    if i == 0 || i == h-1
      puts "#"*w
    else
      puts "#"+ "."*t + "#"
    end
  end
    puts "\n"
end
