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