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


int main(){
	int t,n,m;
	cin >> t;
	double mx = -1e9;
	for(int i = 0 ; i < t ; i++){
		cin >> n >> m;
		double V = 0 , R = 0;
		for(int j = 0 ; j < m ; j++){
			double v,r;
			cin >> v >> r;
			V += v * r;
			R += r;
		}
		mx = max(mx,V/R);
	}
	cin >> n >> m;
	double V = 0 , R = 0;
	for(int j = 0 ; j < m ; j++){
		double v,r;
		cin >> v >> r;
		V += v * r;
		R += r;
	}
	if( mx > V/R+0.0000001) cout << "YES" << endl;
	else cout << "NO" << endl;
}