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>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <chrono>
#include <complex>
using namespace std;
#define ll long long
#define ld long double
#define ui unsigned int
#define ull unsigned ll
#define ls (u << 1)
#define rs (ls | 1)
#define mid (L + R >> 1)
#define mp                   make_pair
#define eb                   emplace_back
#define pb                   push_back
#define pf                   push_front
#define popb                 pop_back
#define popf                 pop_front
#define hashmap              unordered_map
#define hashset              unordered_set
#define lb                   lower_bound
#define ub                   upper_bound
#define all(a)               (a).begin(), (a).end()
#define rall(a)              (a).rbegin(), (a).rend()
#define fi                   first
#define se                   second
#define foi(n) for(ll i=0;i<n;i++)
#define foj(n) for(ll j=0;j<n;j++)
#define fok(n) for(ll k=0;k<n;k++)
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define forrr(i,b,a) for(ll i=b;i>=a;i--)
#define forrrr(i,a,b,k) for(ll i=a;i<b;i=i+k)
#define graph          vector<vector<ll>>
#define sz(v) v.size()
typedef pair<int, int> pii;
typedef pair<ll, ll>   pll;
typedef vector<int>         vi;
typedef vector<ll>          vll;
typedef vector<string>      vs;
typedef vector<double>      vd;
typedef vector<pii>         vpii;
typedef vector<pll>         vpll;
typedef pair< ll, pll>      plll;
typedef vector<plll>      vplll;
typedef  vector<string>       vs;
typedef  vector<char>          vc;
typedef  vector<bool>            vb;
typedef  map<string, int>         msi;
typedef  map<int, int>          mii;
typedef  map<ll, ll>             mll;
typedef  map<ll, vll>             mvll;
typedef  map<char, ll>           mcl;
typedef map<pair<ll, ll>, ll>  mplll;
typedef  unordered_map<char, ll>           umcl;
typedef  unordered_map< ll, char>           umlc;
typedef  map<int, string>      mis;
typedef  pair<string, int>       psi;
typedef  pair<string, string>    pss;
typedef priority_queue <ll> pq;
typedef priority_queue<pii, vector<pii>, greater<pii> > pqq;
typedef priority_queue<ll, vector<ll>, greater<ll>> prq;
const ll MOD = 1000000007;
const ll modx = 998244353;
// ll ceils(ll x, ll y) {
//  return x / y + ((x % y) != 0);
// }
// ll gcd(ll a, ll b) {
//  if (b == 0)
//   return a;
//  else
//   return gcd(b, a % b);
// }


// ll lcm(ll a, ll b) {
//  return a / gcd(a, b) * b;

// }
// ll powmod(ll x, ll y) {
//  ll res = 1;
//  for (ll i = 0; i < y; i++) {
//   res = res * x % MOD;
//  }
//  return res;
// }
// bool isPrime(ll n)
// {
//  if (n <= 1)
//   return false;
//  if (n <= 3)
//   return true;
//  if (n % 2 == 0 || n % 3 == 0)
//   return false;

//  for (ll i = 5; i * i <= n; i = i + 6)
//   if (n % i == 0 || n % (i + 2) == 0)
//   return false;

//  return true;
// }
// bool COMP(pll l, pll r) {
//  return l.ss < r.ss;
// }
// ll kadanesAlgo(vll a)
// {
//  ll n = a.size();

//  ll currMax = 0;
//  ll mx = INT_MIN;

//  foi(n)
//  {
//   currMax += a[i];

//   if (currMax <= a[i])
//   {
//   currMax = a[i];
//   }

//   mx = max(currMax, mx);
//  }
//  return mx;
// }

// void bubbleSort(int array[], int size, int arr2[]) {
//   // loop to access each array element
//   for (int step = 0; step < (size-1); ++step) {
      
//     // loop to compare array elements
//     for (int i = step; i < (size -2); ++i) {

//       // compare two adjacent elements
//       // change > to < to sort in descending order
//       if (array[i] > array[i + 1]) {
//         // swapping elements if elements
//         // are not in the intended order
//         int temp = array[i];
//         array[i] = array[i + 1];
//         array[i + 1] = temp;
//         if(arr2[i]==1){
//             arr2[i]=0;
//         }
//         else{
//             arr2[i]=1;
//         }
//         if(arr2[i+1]==1){
//             arr2[i+1]=0;
//         }
//         else{
//             arr2[i+1]=1;
//         }
//         temp = arr2[i];
//         arr2[i] = arr2[i + 1];
//         arr2[i + 1] = temp;
//       }
//     }
//   }
// }

// const int NN = 202020;
 
// int a[NN], id[NN], ans[NN];
// int mx[NN<<2], mn[NN<<2], flag[NN<<2];
 
// int push_up(int u) {
// 	mx[u] = max(mx[ls], mx[rs]);
// 	mn[u] = min(mn[ls], mn[rs]);
// }
 
// int update(int u, int s) {
// 	mx[u] += s;
// 	mn[u] += s;
// 	flag[u] += s;
// 	return 0;
// }
 
// int push_down(int u) {
// 	if(flag[u] == 0) return 0;
// 	update(ls, flag[u]);
// 	update(rs, flag[u]);
// 	flag[u] = 0;
// }
 
// int build(int u, int L, int R) {
// 	mx[u] = R - 1; mn[u] = L;
// 	flag[u] = 0;
// 	if(L + 1 == R) return 0;
// 	build(ls, L, mid);
// 	build(rs, mid, R);
// }
 
// int update(int u, int L, int R, int st, int ed, int s) {
// 	if(L >= ed || R <= st) return 0;
// 	if(L >= st and R <= ed) {
// 		update(u, s);
// 		return 0;
// 	}
// 	push_down(u);
// 	update(ls, L, mid, st, ed, s);
// 	update(rs, mid, R, st, ed, s);
// 	push_up(u);
// }
 
// int calcMax(int u, int L, int R, int st, int ed) {
// 	if(L >= ed || R <= st) return -1e9;
// 	if(L >= st and R <= ed) {
// 		return mx[u];
// 	}
// 	push_down(u);
// 	return max(calcMax(ls, L, mid, st, ed), calcMax(rs, mid, R, st, ed));
// }
 
// int calcMin(int u, int L, int R, int st, int ed) {
// 	if(L >= ed || R <= st) return 1e9;
// 	if(L >= st and R <= ed) {
// 		return mn[u];
// 	}
// 	push_down(u);
// 	return min(calcMin(ls, L, mid, st, ed), calcMin(rs, mid, R, st, ed));
// }
 
// int solve(int n, int dt) {
// 	build(1, 1, n + 1);
// 	map<int, vector<int> > mp;
// 	for(int i = 1; i <= n; i ++) {
// 		mp[a[i]].push_back(i);
// 	}
// 	for(auto buf : mp) {
// 		for(auto u : buf.second) {
// 			int Mx = calcMax(1, 1, n + 1, u, n + 1);
// 			int Mn = min(0, calcMin(1, 1, n + 1, 1, u));
// 			ans[u] = max(ans[u], (Mx - Mn - dt) / 2);
// 		}
// 		for(auto u : buf.second) {
// 			update(1, 1, n + 1, u, n + 1, -2);
// 		}
// 	}
// }

// int main(){


//     #ifndef ONLINE_JUDGE
//     freopen("input1.txt", "r", stdin);
//     freopen("error1.txt", "w", stderr);
//     freopen("output1.txt", "w", stdout);
//     #endif
//     int n; cin >> n;
// 	for(int i = 1; i <= n; i ++) {
// 		scanf("%d", a + i);
// 	}
// 	solve(n, 0);
// 	for(int i = 1; i <= n; i ++) a[i] *= -1;
// 	solve(n, 1);
	
// 	for(int i = 1; i <= n; i ++) {
// 		printf("%d ", ans[i]);
// 	}
// 	return 0;
// }\

const int N = 1e6 + 7;
const long long mod = 1e9 + 7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n,m;
int k[N];
int al[N];
int ar[N];
int bl[N];
int br[N];
set<pii> L,R;
vpii addL[N],delL[N];
vpii addR[N],delR[N];
 
void solve()
{
        cin >> n >> m;
        forr(i,1,n+1){
                cin >> k[i];
                cin >> al[i] >> bl[i];
                cin >> ar[i] >> br[i];
        }
        L.insert({0, 0});
        R.insert({0, 0});
        forr(i,1,n+1){
                if(L.empty() && R.empty()){
                        cout << "No";
                        return;
                }
                bool f1 = false;
                bool f2 = false;
                if(!L.empty())f1 = true;
                if(!R.empty())f2 = true;
                if(al[i] <= k[i] && k[i] <= bl[i]){
                        while(!R.empty() && R.begin()->fi < ar[i]){
                                delR[i].push_back(*R.begin());
                                R.erase(R.begin());
                        }
                        while(!R.empty() && (--R.end())->fi > br[i]){
                                delR[i].push_back(*(--R.end()));
                                R.erase(--R.end());
                        }
                        if(i > 1 && f1 && ar[i] <= k[i - 1] && k[i - 1] <= br[i] && ar[i - 1] <= k[i - 1] && k[i - 1] <= br[i - 1]){
                                addR[i].push_back({k[i - 1], i - 1});
                                R.insert({k[i - 1], i - 1});
                        }
                }else{
                        while(!R.empty()){
                                delR[i].push_back(*R.begin());
                                R.erase(R.begin());
                        }
                }
                if(ar[i] <= k[i] && k[i] <= br[i]){
                        while(!L.empty() && L.begin()->fi < al[i]){
                                delL[i].push_back(*L.begin());
                                L.erase(L.begin());
                        }
                        while(!L.empty() && (--L.end())->fi > bl[i]){
                                delL[i].push_back(*(--L.end()));
                                L.erase(--L.end());
                        }
                        if(i > 1 && f2 && al[i] <= k[i - 1] && k[i - 1] <= bl[i] && al[i - 1] <= k[i - 1] && k[i - 1] <= bl[i - 1]){
                                addL[i].push_back({k[i - 1], i - 1});
                                L.insert({k[i - 1], i - 1});
                        }
                }else{
                        while(!L.empty()){
                                delL[i].push_back(*L.begin());
                                L.erase(L.begin());
                        }
                }
        }
        if(L.empty() && R.empty()){
                cout << "No";
                return;
        }
        vi ans;
        int st = n;
        int f = 0;
        if(!R.empty())f = 1;
        while(st >= 1){
                if(!f){
                        assert(!L.empty());
                        auto x = *L.begin();
                        while(st > x.se){
                                ans.push_back(1);
                                for(auto y : delL[st])L.insert(y);
                                for(auto y : addL[st])L.erase(y);
                                for(auto y : delR[st])R.insert(y);
                                for(auto y : addR[st])R.erase(y);
                                st--;
                        }
                }else{
                        assert(!R.empty());
                        auto x = *R.begin();
                        while(st > x.se){
                                ans.push_back(0);
                                for(auto y : delL[st])L.insert(y);
                                for(auto y : addL[st])L.erase(y);
                                for(auto y : delR[st])R.insert(y);
                                for(auto y : addR[st])R.erase(y);
                                st--;
                        }
                }
                f ^= 1;
        }
        cout << "Yes\n";
        reverse(ans.begin(), ans.end());
        for(auto x : ans){
                cout << x << " ";
        }
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );
 
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}