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 <set>
#include <iostream>
#include <cmath>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

double exp(){
  int n, m;
  cin >> n >> m;

  double rs = 0.0;
  double ret = 0.0;

  REP(i,m){
    double r, v;
    cin >> v >> r;

    rs += r;
    ret += r * v;
  }

  return ret / rs;
}

int main(){
  int t; cin >> t;
  double my = 0.0;
  REP(i,t) my = max(my, exp());
  double en = exp();
  if(my > en + 0.0000001)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}