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>
#define rmin 1e-9
using namespace std;

int main(){
  double t,n,m,v[100],r[100],e=-1,s,rr,rs;
  double E;
  cin>>t;
  for(int i=0;i<t;i++){
    cin>>n>>m;
    s=0;
    rs=0;
    for(int j=0;j<m;j++) cin>>v[j]>>r[j],rs+=r[j];
    for(int j=0;j<m;j++){
      rr=0;
      while(r[j]>rmin) rr+=r[j],r[j]*=(1-rs);
      s+=rr*v[j];
    }
    e=max(e,s);
  }
  cin>>n>>m;
  s=0;
  rs=0;
  for(int i=0;i<m;i++) cin>>v[i]>>r[i],rs+=r[i];
  for(int i=0;i<m;i++){
    rr=0;
    while(r[i]>rmin) rr+=r[i],r[i]*=(1-rs);
    s+=v[i]*rr;
  }
  E=s;
  if(e>E) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}