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<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  struct Dice{
    Int m;
    vector<double> v,r;
    Dice(Int m):m(m),v(m),r(m){}
  };
  
  auto calc=
    [&](Dice d)->double{
      double sum=0,dom=0;
      for(Int i=0;i<d.m;i++){
        sum+=d.v[i]*d.r[i];
        dom+=d.r[i];
      }
      return sum/dom;      
    };
  
  Int t;
  cin>>t;
  vector<Dice> ds;
  for(Int i=0;i<t;i++){
    Int n,m;
    cin>>n>>m;
    ds.emplace_back(m);
    for(Int j=0;j<m;j++)
      cin>>ds[i].v[j]>>ds[i].r[j];   
  }

  Int p,q;
  cin>>p>>q;
  Dice dd(q);
  for(Int j=0;j<q;j++)
    cin>>dd.v[j]>>dd.r[j];

  const double EPS=0.0000001;
  double res=calc(dd);
  for(Int i=0;i<t;i++){
    if(res+EPS<calc(ds[i])){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}

