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 <vector>
#include <algorithm>
using namespace std;

double calc_e(const vector<int> &v, const vector<double> r, double r0) {
    double e = 0;
    for (int i = 0, size = v.size(); i < size; i++) {
        e += v[i] * r[i];
    }
    e /= r0;
    return e;
}

int main() {
    int t;
    while (cin >> t) {
        double max_e = 0;
        while (t--) {
            int n, m;
            cin >> n >> m;
            vector<int> v(m);
            vector<double> r(m);
            double r0 = 0;
            for (int i = 0; i < m; i++) {
                cin >> v[i] >> r[i];
                r0 += r[i];
            }
            max_e = max(max_e, calc_e(v, r, r0));
        }
        int p, q;
        cin >> p >> q;
        vector<int> v(q);
        vector<double> r(q);
        double r0 = 0;
        for (int i = 0; i < q; i++) {
            cin >> v[i] >> r[i];
            r0 += r[i];
        }
        if (max_e - calc_e(v, r, r0) > 0.0000001) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}