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 <vector>

using namespace std;
typedef long double ll;
const ll eps = 0.0000001;

ll getExpectation( );
void solve();

int main(void) {

	solve();
	return 0;

}

void solve() {

	int t;
	ll emax = -1.0;
	
	cin >> t;

	for (int i = 0; i < t; i++)
		emax = max(emax, getExpectation());

	if (emax > getExpectation() + eps)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return;
	
}

ll getExpectation() {

	int n, m;
	ll e = 0.0;
	ll rsum = 0.0;
	
	cin >> n >> m;
	double v, r;

	for (int i = 0; i < m; i++) {
		cin >> v >> r;
		rsum += r;
		e += r * v;
	}

	return e / rsum;
}