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

const double EPS  = 0.0000001;

int main()
{
  int t;
  while (cin >> t) {
    double E1 = 0.0;
    for (int i = 0; i < t; ++i) {
      int n, m;
      cin >> n >> m;

      double tmp = 0.0, valid = 0.0;
      for (int j = 0; j < m; ++j) {
	int v;
	double r;
	cin >> v >> r;
	tmp += v * r;
	valid += r;
      }
      E1 = max(E1, tmp / valid);
    }

    double E2 = 0.0, valid = 0.0;
    int p, q;
    cin >> p >> q;
    for (int i = 0; i < q; ++i) {
      int v;
      double r;
      cin >> v >> r;
      E2 += v * r;
      valid += r;
    }

    if (E1 - (E2/valid) > EPS)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}