Time Limit: 8 sec / Memory Limit: 64 MB





Example

Input

2
4 2
4 0.4000000
3 0.5000000
4 1
5 0.3333333
5 3
5 0.7777777
4 0.1111111
2 0.0001111


Output

YES
#include<iostream>
#include<algorithm>
#define REP(i, n) for(int i=0;i<(n);++i)
using namespace std;
void chmax(double &a, double b){
    a = max(a, b);
}
double get_dice(){
    int n, m;
    cin >> n >> m;
    double res = 0;
    double ratesum = 0;
    REP(i, m){
        int d;
        double rate;
        cin >> d >> rate;
        res += d * rate;
        ratesum += rate;
    }
    return res / ratesum;
}
int main(){
    int t;
    cin >> t;
    double hd = 0;
    REP(i, t){
        chmax(hd, get_dice());
    }
    double nd = get_dice();
    if(nd < hd - 0.0000001){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

