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>
using namespace std;
int q, n, m, v[111]; double p[111], r[12];
int main() {
	cin >> q;
	for (int i = 0; i <= q; i++) {
		cin >> n >> m;
		double sum = 0.0;
		for (int j = 0; j < m; j++) cin >> v[j] >> p[j], sum += p[j];
		for (int j = 0; j < m; j++) r[i] += v[j] * p[j] / sum;
	}
	bool flag = false;
	for (int i = 0; i < q; i++) if (r[i] > r[q] + 0.0000001) flag = true;
	cout << (flag ? "YES" : "NO") << endl;
	return 0;
}