fun main(args:Array<String>?): Unit {
    while(true) {
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val state = Array(n){ readLine()!!.trim().toCharArray()}
        val depth = state.map{it.takeWhile{c -> c == '.'}.size - 1}
        for (i in state.indices.drop(1)){
            state[i][depth[i]] = '+'
            for (j in 0 until depth[i])
                if (state[i][j] == '.') state[i][j] = ' '
            for (j in (0 until i).reversed().takeWhile{depth[it] > depth[i]})
                state[j][depth[i]] = '|'
        }
        println(
                state.joinToString("\n"){it.joinToString("")}
        )

    }
}
