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 <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n;
ll aa,bb;
vector<pll> bugu[5];

const int N = 1<<15;
set<ll> seg[2*N];

bool query(int l,int r,ll ymn,ll ymx,int a,int b,int k){
  if(r<=a || b<=l)return false;
  if(l<=a && b<=r){
    ll v = *(seg[k].lower_bound(ymn));
    return ymn <= v && v <= ymx;
  }else{
    int m = (a+b)/2;
    return query(l,r,ymn,ymx,a,m,2*k+1) || query(l,r,ymn,ymx,m,b,2*k+2);
  }
}

const ll INF = 1e18;

int main(){
  scanf("%d%lld%lld",&n,&aa,&bb);
  REP(i,n){
    int t;ll x,y;scanf("%d%lld%lld",&t,&x,&y);
    --t;
    bugu[t].push_back(pll(x,y));
  }
  sort(bugu,bugu+5,[&](vector<pll> a,vector<pll> b){return a.size() > b.size();});
  REP(i,5)bugu[i].push_back(pll(0,0));

  // rekkyo
  vector<pll> mp;
  set<ll> xs;
  REP(i,bugu[3].size())REP(j,bugu[4].size()){
    ll x=0, y=0;
    x+=bugu[3][i].first;  y+=bugu[3][i].second;
    x+=bugu[4][j].first;  y+=bugu[4][j].second;
    mp.push_back(pll(x,y));
    xs.insert(x);
  }
  xs.insert(INF);
  xs.insert(-INF);
  // zaatu
  map<ll,int> ids;
  {
    int it = 0;
    for(ll x : xs){
      ids[x] = it++;
    }
  }
  // construct set on segment tree
  REP(i,N){
    seg[i+N-1].insert(INF);
    seg[i+N-1].insert(-INF);
  }
  for(pll P : mp){
    ll x = ids[P.first];
    ll y = P.second;
    seg[x+N-1].insert(y);
  }
  FOR(i,0,N-1){
    int lch = 2*i+1;
    int rch = 2*i+2;
    for(ll y : seg[lch]){
      seg[i].insert(y);
    }
    for(ll y : seg[rch]){
      seg[i].insert(y);
    }
  }

  // query
  REP(i,bugu[0].size())REP(j,bugu[1].size())REP(k,bugu[2].size()){
    ll x=0, y=0;
    x+=bugu[0][i].first;  y+=bugu[0][i].second;
    x+=bugu[1][j].first;  y+=bugu[1][j].second;
    x+=bugu[2][k].first;  y+=bugu[2][k].second;
    // a <= x + tx <= b
    // a <= y + ty <= b
    // a-x <= tx <= b-x
    // a-y <= ty <= b-y
    int leftx = ids.lower_bound(aa-x)->second;
    int rightx = ids.upper_bound(bb-x)->second;
    bool ok = query(leftx,rightx,aa-y,bb-y,0,N,0);
    if(ok){
      puts("Yes");
      return 0;
    }
  }
  puts("No");

  return 0;
}