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 <cstring>
#include <algorithm>
using namespace std;

int v[100];
double r[100];

double calc(int M)
{
	double sum = 0;
	for(int i=0; i<M; i++) sum += r[i];
	for(int i=0; i<M; i++) r[i] /= sum;

	double res = 0;
	for(int i=0; i<M; i++)
		res += r[i] * v[i];

	return res;
}

int main()
{
	int T;
	double mx=0;
	cin >> T; T++;
	while(T--) {
		int N,M;
		cin >> N >> M;
		for(int i=0; i<M; i++)
			cin >> v[i] >> r[i];

		if(T!=0) {
			mx = max(mx, calc(M));
		}
		else {
			cout << (mx > calc(M) ? "YES":"NO") << endl;
		}

	}
	
}