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 <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}

int vs[101];
double rs[101];

void solve(){
    int t;
    cin>>t;
    double maxExp=0;
    for(int i=0;i<t;i++){
        int n,m;
        cin>>n>>m;
        double sumPer=0;
        for(int j=0;j<m;j++){
            cin>>vs[j]>>rs[j];
            sumPer+=rs[j];
        }
        double sum=0;
        for(int j=0;j<m;j++)sum+=vs[j]*(rs[j]/sumPer);
        maxExp=max(maxExp,sum);
    }
    int p,q;
    cin>>p>>q;
    double sumPer2=0;
    for(int j=0;j<q;j++){
        cin>>vs[j]>>rs[j];
        sumPer2+=rs[j];
    }
    double maxExp2=0;
    for(int j=0;j<q;j++)maxExp2+=vs[j]*(rs[j]/sumPer2);
    if(maxExp>maxExp2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

int main(){

    solve();

    return 0;
}