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>
using namespace std;
struct dise{
  int num[100];
  double x[100];
};
int main(){
  int t;
  double top = 0;
  cin >>t;
  while(t--){
    int n,m;
    double sum = 0,all = 0;
    dise d;
    cin >>n>>m;
    for(int i=0; i<m; i++){
      int x;
      double y;
      cin >>x>>y;
      d.num[i] = x;
      d.x[i] = y;
      sum+=y;
    }
    for(int i=0; i<m; i++){
      all+=d.num[i]*(d.x[i]/sum);
    }
    if(all>top){top = all;}
  }
  int n,m;
  double all = 0,sum = 0;
  dise boss;
  cin >>n>>m;
  for(int i=0; i<m; i++){
    int x;
    double y;
    cin >>x>>y;
    boss.num[i] = x;
    boss.x[i] = y;
    sum+=y;
  }    
  for(int i=0; i<m; i++){
    all+=boss.num[i]*(boss.x[i]/sum);
  }
  if(all+0.0000001<top){cout <<"YES"<<endl;}
  else{cout <<"NO"<<endl;}
  return 0;
}