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<algorithm>
using namespace std;
int main(){
	bool ok=false;
	double eps=1e-7;
	int t;scanf("%d",&t);
	double val=0;
	while(t--){
		int a,b;scanf("%d%d",&a,&b);
		double p=0;
		double ex=0;
		for(int i=0;i<b;i++){
			int q;double r;scanf("%d%lf",&q,&r);
			p+=r;ex+=r*q;
		}
		ex/=p;
		val=max(val,ex);
	}
	int a,b;scanf("%d%d",&a,&b);
	double p=0;double ex=0;
	for(int i=0;i<b;i++){
		int q;double r;scanf("%d%lf",&q,&r);
		p+=r;ex+=r*q;
	}
	ex/=p;
	if(ex+eps<val)printf("YES\n");else printf("NO\n");
}