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 <string>
#include <vector>
#include <iostream>
#include <algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
  int n;
  cin>>n;
  vector<double>s(n+1);
  rep(i,n+1){
    int m;
    cin>>m>>m;
    double sum=0;
    while(m--){
      double a,b;
      cin>>a>>b;
      sum+=b;
      s[i]+=a*b;
    }
    s[i]/=sum;
  }
  bool h=false;
  rep(i,n)if(s[i]>s[n]+1e-10)h=true;
  if(h)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}