fun main(args:Array<String>?): Unit {
    while(true){
        val (x, y, z) = readLine()!!.trim().split(' ').map(String::toInt)
        if (x == 0 && y == 0 && z == 0) return
        val roulette = readLine()!!.trim().split(' ').map(String::toInt)
        val cells = Array(y){ Event.None as Event}
        repeat(z){
            val (n, e, a) = readLine()!!.trim().split(' ').map(String::toInt)
            cells[n] = when(e){
                1 -> Event.Move(a)
                2 -> Event.Gain(a)
                3 -> Event.Loss(a)
                else -> TODO()
            }
        }
        println(solve(cells, roulette).toInt())
    }
}
fun solve(cells: Array<Event>, roulette: List<Int>): Double {
    val memo = Array(cells.size){DoubleArray(it * 100 + 1){-1.0}}
    fun sub(position: Int, money: Int, event: Boolean = true): Double {
        if (position !in cells.indices) return money.toDouble()
        if (!event) return roulette.map{sub(position + it, money)}.sum() / roulette.size
        if (memo[position][money] < 0){
            val cell = cells[position]
            memo[position][money] = when(cell){
                is Event.Move -> sub(position + cell.step, money, false)
                is Event.Gain -> roulette.map{sub(position + it, money + cell.value)}.sum() / roulette.size
                is Event.Loss -> if (cell.value > money) roulette.map{sub(position + it, 0)}.sum() / roulette.size else roulette.map{sub(position + it, money - cell.value)}.sum() / roulette.size
                Event.None -> roulette.map{sub(position + it, money)}.sum() / roulette.size
            }
        }
        return memo[position][money]
    }
    return sub(0, 0)
}
sealed class Event {
    data class Move(val step: Int): Event()
    data class Gain(val value: Int): Event()
    data class Loss(val value: Int): Event()
    object None: Event()
}
