while true
    rect = gets.split.map(&to_i)
    break if (rect[0] == 0 && rect[1] == 0)
    H = rect[0]-2
    W = rect[1]-2
    
    H.times do
        print "#"
        W.times do
            print "."
        end
        puts "#"
    end
    
end