import java.util.*

fun main(args: Array<String>?): Unit {
    while(true){
        val (n, m, h, k) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0) return
        val rails = Array(n){arrayListOf<Train>()}
        repeat(m){
            val (a, b, c, hr, r) = readLine()!!.trim().split(' ').map(String::toInt)
            rails[a - 1].add(Train(b - 1, c, hr, r - 1))
            rails[b - 1].add(Train(a - 1, c, hr, r - 1))
        }
        val (start, goal) = readLine()!!.trim().split(' ').map{it.toInt() - 1}
        val passports = List(readLine()!!.toInt()){
            val info = readLine()!!.trim().split( ' ').map(String::toInt)
            Passport(info[1], info.takeLast(info[0]).map{it - 1})
        }
        val minPassportPrice = IntArray(1 shl k){Int.MAX_VALUE}.also{it[0] = 0}
        for (p in passports) for (i in minPassportPrice.indices.reversed()) if (minPassportPrice[i] != Int.MAX_VALUE && minPassportPrice[p.company.flag or i] > minPassportPrice[i] + p.price) {
            minPassportPrice[p.company.flag or i] = minPassportPrice[i] + p.price
        }
        val memo = Array(h + 1){IntArray(n){Int.MAX_VALUE}}
        val queue = PriorityQueue<Triple<Int, Int, Int>>(compareBy(Triple<*, *, Int>::third))
        var min = null as Int?
        for (passport in minPassportPrice.withIndex().filter{it.value != Int.MAX_VALUE}.map{Passport(it.value, Flag(it.index))}) {
            memo.forEach { it.fill(Int.MAX_VALUE) }
            queue.clear()
            memo[0][start] = passport.price
            queue.add(Triple(0, start, passport.price))
            while(queue.isNotEmpty() && queue.peek().second != goal){
                val (hour, current, cost) = queue.poll()
                for (train in rails[current]) {
                    if (passport.company.isOn(train.company) && hour + train.time <= h && memo[hour + train.time][train.to] > cost) {
                        memo[hour + train.time][train.to] = cost
                        queue.add(Triple(hour + train.time, train.to, cost))
                    }else if (passport.company.isOff(train.company) && hour + train.time <= h && memo[hour + train.time][train.to] > cost + train.cost) {
                        memo[hour + train.time][train.to] = cost + train.cost
                        queue.add(Triple(hour + train.time, train.to, cost + train.cost))
                    }
                }
            }
            if (queue.isNotEmpty() && queue.peek().second == goal && (min == null || min > queue.peek().third)) min = queue.peek().third
        }
        println(min ?: -1)
    }
}
data class Train(val to: Int, val cost :Int, val time: Int, val company: Int)
data class Passport(val price: Int, val company: Flag) {
    constructor(price: Int, flags: List<Int>): this(price, Flag(flags))
}
data class Flag(val flag: Int) {
    constructor(flags: List<Int>): this(flags.fold(0){a, b -> a or (1 shl b)})
    fun isOn(value: Int): Boolean = (flag and (1 shl value)) != 0
    fun isOff(value: Int): Boolean = !isOn(value)
    fun add(value: Int): Flag = Flag(flag or (1 shl value))
    fun merge(other: Flag): Flag = Flag(flag or other.flag)
}

