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 <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-7;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

double E() {
  int m;
  scanf("%*d %d", &m);
  double all = 0.0;
  double sum = 0.0;
  REP(i, m) {
    double v, p;
    scanf("%lf %lf", &v, &p);
    sum += v * p;
    all += p;
  }
  sum /= all;
  return sum;
}

int main() {
  int n;
  while (scanf("%d", &n) > 0) {
    double player = 0.0;
    REP(i, n) {
      double e = E();
      player = max(player, e);
    }
    double enemy = E();
    puts(player - enemy > EPS ? "YES" : "NO");
  }
}