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 <cstdio>
#include <algorithm>
using namespace std;
#define EPS 0.0000001
int main() {
    int t; scanf("%d",&t);
    double max_v=0.0;
    for (int i=0; i<t; i++) {
        double v=0.0, r=1.0;
        int n, m; scanf("%d%d",&n,&m);
        for (int j=0; j<m; j++) {
            int vj;
            double rj;
            scanf("%d%lf",&vj,&rj);
            v+=vj*rj;
            r-=rj;
        }
        double x=1.0, y=0.0;
        for (int j=0; j<100; j++) {
            y+=v*x;
            x*=r;
        }
        max_v=max(max_v,y);
    }
    int p, q; scanf("%d%d",&p,&q);
    double boss=0.0, br=1.0;
    for (int i=0; i<q; i++) {
        int vi;
        double ri;
        scanf("%d%lf",&vi,&ri);
        boss+=vi*ri;
        br-=ri;
    }
    double bx=1.0, by=0.0;
    for (int i=0; i<100; i++) {
        by+=boss*bx;
        bx*=br;
    }
    if (by+EPS<=max_v) puts("YES");
    else puts("NO");
}