Problem: Problem

Gaccho is enthusiastic about the popular game Zombie Hunter. In this game, there are 5 types of armor dedicated to the head, torso, arms, hips, and legs, and the player character (PC) operated by Gaccho can have up to 1 armor for each part of the body. Can be equipped.
In addition, the weight and defense power are set for each armor, and when the total weight of the armor equipped on the PC is A or more and B or less, and the total defense power is also A or more and B or less. The PC can activate the skill.

Gaccho has N pieces of armor. Find out if your PC can activate your skills by choosing the right armor to equip.

Constraints

The input satisfies the following conditions.

* 1 ≤ N ≤ 500
* 1 ≤ A ≤ B ≤ 1012
* 1 ≤ ti ≤ 5
* −1012 ≤ xi, yi ≤ 1012

Input

The input is given in the following format.


N A B
t1 x1 y1
t2 x2 y2
...
tN xN yN


All inputs are given as integers.
The first line gives you the number of armor N you own and the two integers A and B used to activate the skill.
Information on N pieces of armor is given to the N lines that continue from the second line. ti, xi, yi represent the type, weight, and defense of the i-th armor, respectively.

Armor type The ti value indicates that 1 is head armor, 2 is torso armor, 3 is arm armor, 4 is waist armor, and 5 is foot armor.

Output

Output "Yes" if the skill can be activated, and "No" if it cannot be activated on one line.

Examples

Input

7 10 11
1 1 0
1 0 1
2 2 2
3 3 5
4 1 3
5 1 3
5 5 -1


Output

Yes


Input

7 10 10
1 1 0
1 0 1
2 2 2
3 3 5
4 1 3
5 1 3
5 5 -1


Output

No

Solution (in CPP):

Solution:
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;

int n; ll a, b;
void solve() {
	vector<LP> v[5];
	rep(i, 5)v[i].push_back({ 0,0 });
	cin >> n >> a >> b;
	vector<LP> le, ri;
	rep(i, n) {
		int t; cin >> t; t--;
		ll x, y; cin >> x >> y;
		v[t].push_back({ x,y });
	}
	rep(i, v[0].size()) {
		rep(j, v[1].size()) {
			LP nex = { 0,0 };
			nex.first = v[0][i].first + v[1][j].first;
			nex.second = v[0][i].second + v[1][j].second;
			le.push_back(nex);
		}
	}
	rep(i, v[2].size()) {
		rep(j, v[3].size()) {
			rep(k, v[4].size()) {
				LP nex = { 0,0 };
				nex.first = v[2][i].first + v[3][j].first + v[4][k].first;
				nex.second = v[2][i].second + v[3][j].second + v[4][k].second;
				ri.push_back(nex);
			}
		}
	}
	sort(le.begin(), le.end());
	sort(ri.begin(), ri.end());
	ll x = le[0].first;
	multiset<ll> st;
	//[l,r)
	int l = (int)ri.size(), r = ri.size();
	rep(i, ri.size()) {
		ll sum = ri[i].first + le[0].first;
		if (sum >= a && sum <= b) {
			st.insert(ri[i].second);
		}
		if (ri[i].first >= a - le[0].first) {
			l = min(l, i);
		}
		if (ri[i].first > b - le[0].first) {
			r = min(r, i);
		}
	}
	{
		ll cl = a - le[0].second, cr = b - le[0].second;
		if (st.count(cl)) {
			cout << "Yes" << endl; return;
		}
		st.insert(cl);
		auto itr = st.find(cl);
		itr++;
		if (itr != st.end()) {
			ll z = *itr;
			if (z <= cr) {
				cout << "Yes" << endl; return;
			}
		}
		st.erase(st.find(cl));
	}
	rep1(i, (int)le.size()-1) {
		while (l > 0 && le[i].first + ri[l-1].first >= a) {
			l--;
			st.insert(ri[l].second);
		}
		while (r > 0 && le[i].first + ri[r-1].first > b) {
			r--;
			st.erase(st.find(ri[r].second));
		}
		ll cl = a - le[i].second, cr = b - le[i].second;
		if (st.count(cl)) {
			cout << "Yes" << endl; return;
		}
		st.insert(cl); 
		auto itr = st.find(cl);
		itr++;
		if (itr != st.end()) {
			ll z = *itr;
			if (z <= cr) {
				cout << "Yes" << endl; return;
			}
		}
		st.erase(st.find(cl));
	}
	cout << "No" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	solve();
	//stop
		return 0;
}