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 <string>
//#include <math.h>
using namespace std;

double getExpe() {
  int n, m;
  cin >> n >> m;
  double expe = 0;
  double sumR = 0;
  for (int i = 0; i < m; i++) {
    int v;
    double r;
    cin >> v >> r;
    expe += v*r;
    sumR += r;
  }
  return expe / sumR;
}

int main() {
  int t;
  cin >> t;
  double maxExpe = 0;
  for (int i = 0; i < t; i++) {
    double expe = getExpe();
    if(maxExpe < expe) maxExpe = expe;
  }
  cout << ((maxExpe >= getExpe() + 0.0000001) ? "YES" : "NO") << endl;
  return 0;
}