fun main(args:Array<String>?): Unit {
    val t = readLine()!!.trim().toInt()
    val dices = Array(t){
        val (_, m) = readLine()!!.trim().split(' ').map(String::toInt)
        List(m){
            val (v, r) = readLine()!!.trim().split( ' ').map(String::toDouble)
            Pair(v, r)
        }.let{it.sumByDouble { (v, r) -> v * r } / it.sumByDouble { (_, r) -> r }}
    }
    val (_, q) = readLine()!!.trim().split(' ').map(String::toInt)
    val estimated = List(q){
        val (v, r) = readLine()!!.trim().split(' ').map(String::toDouble)
        Pair(v, r)
    }.let{it.sumByDouble { (v, r) -> v * r } / it.sumByDouble { (_, r) -> r }}
    println(
            if (dices.any{it > estimated + 0.0000001}) "YES" else "NO"
    )
}
