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<cstdio>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

double calc(int m,int *score,double *pr){
	double sum=0,ex=0;
	rep(i,m) sum+=pr[i];
	rep(i,m) ex+=score[i]*pr[i]/sum;
	return ex;
}

int main(){
	double ex_max=0,ex_enemy;
	int n; scanf("%d",&n);
	rep(t,n+1){
		int m; scanf("%*d%d",&m);
		int score[100];
		double pr[100];
		rep(i,m) scanf("%d%lf",score+i,pr+i);
		if(t<n) ex_max=max(ex_max,calc(m,score,pr));
		else    ex_enemy=calc(m,score,pr);
	}

	puts(ex_max-ex_enemy>1e-7?"YES":"NO");

	return 0;
}