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 <cmath>
using namespace std;

int main(){
	int t;
	int n[11], m[11];
	double E[11];
	
	cin >> t;
	for(int i=0 ; i < t ; i++ ){
		cin >> n[i] >> m[i];
		
		int v[101];
		double r[101];
		for(int j=0 ; j < m[i] ; j++ ){
			cin >> v[j] >> r[j];
		}
		
		double white = 1.0;
		for(int j=0 ; j < m[i] ; j++ ){
			white -= r[j];
		}
		double e = 0.0;
		for(int j=0 ; ; j++ ){
			double sum = 0.0;
			for(int k=0 ; k < m[i] ; k++ ){
				sum += v[k] * r[k] * pow( white , (double)j );
			}
			e += sum;
			if( sum < 1e-7 ){
				break;
			}
		}
		E[i] = e;
	}
	int p, q, v[101];
	double r[101];
	cin >> p >> q;
	for(int i=0 ; i < q ; i++ ){
		cin >> v[i] >> r[i];
	}
	
	double white = 1.0;
	for(int j=0 ; j < q ; j++ ){
		white -= r[j];
	}
	double e = 0.0;
	for(int j=0 ; ; j++ ){
		double sum = 0.0;
		for(int k=0 ; k < q ; k++ ){
			sum += v[k] * r[k] * pow( white , (double)j );
		}
		e += sum;
		if( sum < 1e-7 ){
			break;
		}
	}
	bool flag = false;
	//cout << "e:" << e << endl;
	for(int i=0 ; i < t ; i++ ){
		//cout << "E[" << i << "]:" << E[i] << endl;
		if( e < E[i] ){
			flag = true;
		}
	}
	if( flag )
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}