def c(x,y,h,w)
  x == 0 || y == 0 || x == w-1 || y == h-1 ? ?# : ?.
end

loop {
  h, w = gets.split.map(&:to_i)

  break if h == 0 && w == 0
  
  h.times{|y|
    w.times{|x| print c(x,y,h,w) }
    puts
  }
  puts
}

