loop {
    h, w = gets.split(" ").map(&:to_i)
    if h == 0 && w == 0
        break
    end
    w.times{print "#"}
    puts "\n"
    h-2.times{
        print "#"
         w-2.times {
             print "."
         }
         print "#"
         puts "\n"
    }
    w.times{print "#"}
    puts "\n"
    puts "\n"
}