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 "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

using ld= long double;

struct dice {
	vector<pair<int,ld>>mp;
	ld score() {
		ld sum=0;
		ld per=0;
		for (auto m : mp) {
			sum+=m.first*m.second;
			per+=m.second;
		}
		return sum/per;
	}
};

int main() {
	int T;cin>>T;
	vector<dice>my_dices;
	for (int i = 0; i < T; ++i) {
		dice di;
		int N,M;cin>>N>>M;
		for (int i = 0; i < M; ++i) {
			int v;ld r;cin>>v>>r;
			di.mp.emplace_back(v,r);
		}
		my_dices.push_back(di);
	}
	dice op_dice;
	{
		dice di;
		int N, M; cin >> N >> M;
		for (int i = 0; i < M; ++i) {
			int v; ld r; cin >> v >> r;
			di.mp.emplace_back(v, r);
		}
		op_dice=di;
	}
	bool ok=false;
	for (auto md : my_dices) {
		if (md.score() > op_dice.score() + 0.0000001) {
			ok=true;
		}
	}
	if (ok) {
		cout<<"YES"<<endl;
	}
	else {
		cout<<"NO"<<endl;
	}
	return 0;
}
