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>
#include<cstring>
using namespace std;

int main(){
  int t;
  cin>>t;
  double ans[t+1];
  for(int i=0;i<t+1;i++){
    //cout << "i " << i << endl;
    int n,m;
    cin>>n>>m;
    int val[m];
    double p[m];
    for(int j=0;j<m;j++){
      cin>>val[j]>>p[j];
    }
    //cout << "val" << endl;
    //for(int a:val)cout << a << endl;
    double pp=0;
    for(int k=0;k<m;k++) pp+=p[k];
    for(int j=0;j<m;j++){
      p[j]/=pp;
      //cout << "p["<<j<<"] "<<p[j] << endl;
    }
    for(int j=0;j<m;j++){
      ans[i]+=val[j]*p[j];
    }
    //cout << endl;
  }
  bool flag = false;
  //for(double a:ans)cout << a << endl;
  for(int i=0;i<t;i++){
    if(ans[t] < ans[i]){
      cout << "YES" << endl;
      flag=true;
      break;
    }
  }
  if(flag==false)
    cout << "NO" << endl;
  return 0;
}