Problem: The Alice's computer is broken, so she can't play her favorite card game now. To help Alice, Bob wants to answer n her questions. 

Initially, Bob holds one card with number 0 in the left hand and one in the right hand. In the i-th question, Alice asks Bob to replace a card in the left or right hand with a card with number k_i (Bob chooses which of two cards he changes, Bob must replace exactly one card).

After this action, Alice wants the numbers on the left and right cards to belong to given segments (segments for left and right cards can be different). Formally, let the number on the left card be x, and on the right card be y. Then after the i-th swap the following conditions must be satisfied: a_{l, i} ≤ x ≤ b_{l, i}, and a_{r, i} ≤ y ≤ b_{r,i}.

Please determine if Bob can answer all requests. If it is possible, find a way to do it.

Input

The first line contains two integers n and m (2 ≤ n ≤ 100 000, 2 ≤ m ≤ 10^9) — the number of questions and the maximum possible value on the card.

Then n queries are described. Every description contains 3 lines.

The first line of the description of the i-th query contains a single integer k_i (0 ≤ k_i ≤ m) — the number on a new card.

The second line of the description of the i-th query contains two integers a_{l, i} and b_{l, i} (0 ≤ a_{l, i} ≤ b_{l, i} ≤ m) — the minimum and maximum values of the card at the left hand after the replacement.

The third line of the description of the i-th query contains two integers a_{r, i} and b_{r,i} (0 ≤ a_{r, i} ≤ b_{r,i} ≤ m) — the minimum and maximum values of the card at the right hand after the replacement.

Output

At the first line, print "Yes", if Bob can answer all queries, and "No" otherwise.

If Bob can answer all n queries, then at the second line print n numbers: a way to satisfy all requirements. If in i-th query Bob needs to replace the card in the left hand, print 0, otherwise print 1. If there are multiple answers, print any.

Examples

Input


2 10
3
0 3
0 2
2
0 4
0 2


Output


Yes
0 1 

Input


2 10
3
0 3
0 2
2
3 4
0 1


Output


No

Input


5 10
3
0 3
0 3
7
4 7
1 3
2
2 3
3 7
8
1 8
1 8
6
1 6
7 10


Output


Yes
1 0 0 1 0 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;

#define int int64_t //be careful about this 
#define endl "\n"

#define pr pair
#define ar array
#define fr first
#define sc second
#define vt vector
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

#define SZ(x) ((int)(x).size())
#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a, b, sizeof(a))

template<class A> void rd(vt<A>& v);
template<class T> void rd(T& x){ cin >> x;}
template<class H, class... T> void rd(H& h, T&... t) { rd(h); rd(t...);}
template<class A> void rd(vt<A>& x) { for(auto& a : x) rd(a);}

template<class T> bool ckmin(T& a, const T b) { return b < a ? a = b, 1 : 0;}
template<class T> bool ckmax(T& a, const T b) { return a < b ? a = b, 1 : 0;}

template<typename T>
void __p(T a) {
  cout<<a; 
}
template<typename T, typename F>
void __p(pair<T, F> a) {
  cout<<"{";
  __p(a.first);
  cout<<",";
  __p(a.second);
  cout<<"}\n"; 
}
template<typename T>
void __p(std::vector<T> a) {
  cout<<"{";
  for(auto it=a.begin(); it<a.end(); it++)
    __p(*it),cout<<",}\n"[it+1==a.end()]; 
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
  __p(a1);
  __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cout<<name<<" : ";
  __p(arg1);
  cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  int bracket=0,i=0;
  for(;; i++)
    if(names[i]==','&&bracket==0)
      break;
    else if(names[i]=='(')
      bracket++;
    else if(names[i]==')')
      bracket--;
  const char *comma=names+i;
  cout.write(names,comma-names)<<" : ";
  __p(arg1);
  cout<<" | ";
  __f(comma+1,args...);
}


void setIO(string s = "") {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
  // remove this when size of input is not fixed.
  cin.exceptions(cin.failbit); 
	cout.precision(15);	cout << fixed;
  if(SZ(s)){
  	freopen((s+".in").c_str(),"r",stdin);
  	freopen((s+".out").c_str(),"w",stdout);
  }
}


/*/--------------------------------------------------look below-----------------------------------------------------------------------------------/*/







































template<class T> 
struct static_range_min_query {
	
	int level(int x) {
		return 31 - __builtin_clz(x);
	}
	
	vector<T> v;
	vector<vector<int>> jmp;
	
	int comb(int a, int b){
		return v[a] == v[b] ? min(a,b) : (v[a] < v[b] ? a : b);
	}
	
	void init(const vector<T> & _v){
		v = _v; 
		jmp = {vector<int> (int(_v.size()))};
		iota(begin(jmp[0]),end(jmp[0]),0);
		for(int j = 1; (1 << j) <= int(_v.size()); ++j){
			jmp.push_back(vector<int> (int(_v.size()) - (1 << j) + 1));
			for(int i = 0; i < int(jmp[j].size()); ++i){
				jmp[j][i] = comb(jmp[j-1][i], jmp[j-1][i + (1 << (j - 1))]);
			}
		}	
	}
	
	int index(int l, int r){
		assert(l <= r);
		int d = level(r - l + 1);
		return comb(jmp[d][l], jmp[d][r - (1 << d) + 1]);
	}
	
	T query(int l, int r){
		return v[index(l,r)];
	}
	
};

template<class T> 
struct static_range_max_query {
	
	int level(int x) {
		return 31 - __builtin_clz(x);
	}
	
	vector<T> v;
	vector<vector<int>> jmp;
	
	int comb(int a, int b){
		return v[a] == v[b] ? min(a,b) : (v[a] > v[b] ? a : b);
	}
	
	void init(const vector<T> & _v){
		v = _v; 
		jmp = {vector<int> (int(_v.size()))};
		iota(begin(jmp[0]),end(jmp[0]),0);
		for(int j = 1; (1 << j) <= int(_v.size()); ++j){
			jmp.push_back(vector<int> (int(_v.size()) - (1 << j) + 1));
			for(int i = 0; i < int(jmp[j].size()); ++i){
				jmp[j][i] = comb(jmp[j-1][i], jmp[j-1][i + (1 << (j - 1))]);
			}
		}	
	}
	
	int index(int l, int r){
		assert(l <= r);
		int d = level(r - l + 1);
		return comb(jmp[d][l], jmp[d][r - (1 << d) + 1]);
	}
	
	T query(int l, int r){
		return v[index(l,r)];
	}
	
};

// left-right refer to cards and start-end refers to range.

static_range_min_query<int> range_minl, range_minr;
static_range_max_query<int> range_maxl, range_maxr; 

bool in(int x, int l, int r){
	return l <= x && x <= r;
}

signed main(){
  setIO();
  int n,m; rd(n,m);
  
  vt<int> k(n+1,0), sl(n+1,0), el(n+1,0), sr(n+1,0), er(n+1,0);
  
  for(int i = 1; i <= n; ++i){
  	rd(k[i],sl[i],el[i],sr[i],er[i]);
  }
  
  
  range_maxl.init(sl);
  range_minl.init(el);
  
  range_maxr.init(sr);
  range_minr.init(er);
  
  
  vt<int> tl(n+1,-1), tr(n+1,-1);
  
  for(int i = n; i >= 0; --i){
  	int x = k[i];
  	if(!in(x,sl[i],el[i])) continue;
  	int lo = i, hi = n + 1;
  	while(hi - lo > 1){
  		int mid = (hi + lo)/2;
  		in(x,range_maxl.query(i,mid),range_minl.query(i,mid)) ? lo = mid : hi = mid;
  	}
  	tl[i] = lo;
  }
  
  for(int i = n; i >= 0; --i){
  	int x = k[i];
  	if(!in(x,sr[i],er[i])) continue;
  	int lo = i, hi = n + 1;
  	while(hi - lo > 1){
  		int mid = (hi + lo)/2;
  		in(x,range_maxr.query(i,mid),range_minr.query(i,mid)) ? lo = mid : hi = mid;
  	}
  	tr[i] = lo;
  }
  
  
  vt<int> nl(n+1,-1), nr(n+1,-1);
  // nr = k[i] is on right and max index s.t. cards are placed on top of it.
  
  for(int i = n; i >= 0; --i){
  	int x = k[i];
  	if(!in(x,sl[i],el[i])) continue;
  	nl[i] = i;
  	if(i < n && nl[i+1] != -1) nl[i] = nl[i+1];
  }
  
  for(int i = n; i >= 0; --i){
  	int x = k[i];
  	if(!in(x,sr[i],er[i])) continue;
  	nr[i] = i;
  	if(i < n && nr[i+1] != -1) nr[i] = nr[i+1];
  }
  
  // if a[i] = 1, a[i+1] = 0 when does a[i+x] ends - nxt1.
  // 0 -> left, 1 -> right.
  vt<int> nxt0(n,-1), nxt1(n,-1);
  
  
  // lastest0 :- latest index from where we get 0 1 1 ..
  // lastest1 :- latest index from where we get 1 0 0 ..
  int latest0 = -1, latest1 = -1;
  
  for(int i = n - 1; i >= 0; --i){
  	//calc nxt0
  	
  	//check whether its possible to take it till the end
  	if(tl[i] == n && nr[i+1] == n){
  		nxt0[i] = n;
  	}else{
  		if(latest1 != -1){
  			if(tl[i] >= latest1 && nr[i+1] >= latest1){
  				nxt0[i] = latest1;
  			}
  		}
  	}
  	
  	//calc nxt1
  	
  	//check whether its possible to take it till the end
  	if(tr[i] == n && nl[i+1] == n){
  		nxt1[i] = n;
  		latest1 = i;
  	}else{
  		if(latest0 != -1){
  			if(tr[i] >= latest0 && nl[i+1] >= latest0){
  				nxt1[i] = latest0;
  			}
  		}
  	}
  	
  	//__f("i,nxt0[i],nxt1[i]",i,nxt0[i],nxt1[i]);
  	
  	if(nxt0[i] != -1) latest0 = i;
  	if(nxt1[i] != -1) latest1 = i;
  }
  
  vt<int> ans(n+1);
  
  if(nxt0[0] != -1){
  	cout << "Yes" << endl;
  	
  	int now = 0, j = 0;
  	while(j < n){
  		int from = j + 1, to = (now == 0 ? nxt0[j] : nxt1[j]);
  		assert(from <= to);
  		for(int i = from; i <= to; ++i) ans[i] = (now^1);
  		j = to; now^=1;
  	}
  	
  	for(int i = 1; i <= n; ++i) cout << ans[i] << " ";
  	
  }else if(nxt1[0] != -1){
  	cout << "Yes" << endl;
  	
  	int now = 1, j = 0;
  	while(j < n){
  		int from = j + 1, to = (now == 0 ? nxt0[j] : nxt1[j]);
  		assert(from <= to);
  		for(int i = from; i <= to; ++i) ans[i] = (now^1);
  		j = to; now^=1;
  	}
  	
  	for(int i = 1; i <= n; ++i) cout << ans[i] << " ";
  	
  }else{
  	cout << "No";
  }
  
  
}