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 <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int num_dice;
	scanf("%d",&num_dice);

	double maximum = -1.0,tmp,tmp_exp;

	int n,m;
	double value[100],prob[100];

	for(int loop = 0; loop < num_dice; loop++){
		scanf("%d %d",&n,&m);
		tmp = 0;

		for(int i = 0; i < m; i++){
			scanf("%lf %lf",&value[i],&prob[i]);
			tmp += prob[i];
		}

		tmp_exp = 0;
		for(int i = 0; i < m; i++){
			tmp_exp += value[i]*prob[i]*(1+(1-tmp)/tmp);
		}
		maximum = max(maximum,tmp_exp);
	}

	int p,q;
	scanf("%d %d",&p,&q);
	tmp = 0;
	for(int i = 0; i < q; i++){
		scanf("%lf %lf",&value[i],&prob[i]);
		tmp += prob[i];
	}
	double parent_exp = 0;
	for(int i = 0; i < q; i++){
		parent_exp += value[i]*prob[i]*(1+(1-tmp)/tmp);
	}

	if(parent_exp+ 0.0000001 < maximum){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}