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 <algorithm>
using namespace std;

double calc(int m, int v[], double r[]) {
  double a,b = 0.0;
  a = b = 0;
  for(int i = 0; i < m; ++i) {
    a += r[i];
    b += r[i]*v[i];
  }
  return b/a;
}

int main() {
  int t;
  cin >> t;
  ++t;
  double maxE = 0.0;
  int n, m, v[100];
  double r[100];
  while(t--) {
    cin >> n >> m;
    for(int i = 0; i < m; ++i) cin >> v[i] >> r[i];
    if(t == 0) {
      if(maxE - calc(m,v,r) > 0.0000001) cout << "YES" << endl;
      else cout << "NO" << endl;
    } else {
      maxE = max(maxE, calc(m,v,r));
    }
  }

  return 0;
}