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>

using namespace std;

double compute_e(int n, int m, int v[], double r[]) {
    double e = 0;
    double normalizing = 0;
    for (int i = 0; i < m; ++i) {
        e += v[i] * r[i];
        normalizing += r[i];
    }
    e /= normalizing;
    return e;
}

int main() {
    int t, n, m, p, q;
    int v[100];
    double r[100];
    double e_leader = 0;
    double e_max = -1;
    cin >> t;
    for (int i = 0; i < t; ++i) {
        cin >> n >> m;
        for (int j = 0; j < m; ++j) {
            cin >> v[j] >> r[j];
        }
        e_max = max(e_max, compute_e(n, m, v, r));
    }
    cin >> p >> q;
    for (int i = 0; i < q; ++i) {
        cin >> v[i] >> r[i];
    }
    e_leader = compute_e(p, q, v, r);
    if (e_max > e_leader + 0.0000001) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}