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:
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include <functional>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<numeric>
#include<chrono>
#include<sstream>
#include <valarray> 
#include<list>
#include<complex>
#include<cassert>


typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define forn(i,n) for(int i = 0;i<n;i++)
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define szof(x) int(x.size())
#define sqr(x) ((x)*(x))
#define debug(x) cerr<<#x<<" = "<<x<<'\n' 

using namespace std;

const int INF = 1000000000 + 1e8;
const ll LINF = 2000000000000000000;


const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

ll l[N];
ll r[N];

void inc(int i1, int change, ll* t) {
	for (int i = i1; i < N; i = i | (i + 1)) {
		t[i] += change;
	}
}

ll prefix(int i1, ll* t) {
	ll res = 0;
	for (int i = i1; i >= 0; i = (i & (i + 1)) - 1) {
		res += t[i];
	}
	return res;
}

//возвращает prefix [i1, i2]
ll prefix(int i1, int i2, ll* t) {
	return prefix(i2, t) - (i1 == 0 ? 0 : prefix(i1 - 1, t));
}


const int SEGTREE_SIZE = 2e5 + 10;
const ll NO_OPERATION = 1e18 + 5;

struct segtree {

	struct node {
		ll set;
		ll min;
		ll max;
	};

	vector<node> t;
	int size;

	const node NEUTRAL_ELEM = { NO_OPERATION, LINF, -LINF };
	const node ZERO = { NO_OPERATION , 0, 0 };


	void modify_op(ll& a, ll b, ll len) {
		if (b == NO_OPERATION)
			return;
		if (a == NO_OPERATION) {
			a = b * len;
		}
		else {
			a += b * len;
		}
	}


	node sum_op(node &a, node &b) {
		node res;
		res.min = min(a.min, b.min);
		res.max = max(a.max, b.max);
		res.set = NO_OPERATION;

		return res;
	}


	void push(int v, int tl, int tr) {
		if (t[v].set == NO_OPERATION || tr - tl == 1) {
			return;
		}
		int tm = (tr + tl) / 2;
		modify_op(t[v * 2 + 1].set, t[v].set, 1);
		modify_op(t[v * 2 + 1].min, t[v].set, 1);
		modify_op(t[v * 2 + 1].max, t[v].set, 1);

		modify_op(t[v * 2 + 2].set, t[v].set, 1);
		modify_op(t[v * 2 + 2].min, t[v].set, 1);
		modify_op(t[v * 2 + 2].max, t[v].set, 1);

		t[v].set = NO_OPERATION;
	}


	void init(int n) {
		size = 1;
		while (size < n) {
			size *= 2;
		}
		t.assign(2 * size, ZERO);
	}

	segtree(int n = SEGTREE_SIZE) {
		init(n);
	}

	segtree(vector<pii>& a) {
		init(a.size());
		build(a);
	}


	void build(vector<pii>& a, int v, int tl, int tr) {
		if (tr - tl == 1) {
			if (tl < a.size())
				t[v] = { NO_OPERATION, a[tl].second, a[tl].first };
			return;
		}
		int tm = (tr + tl) / 2;
		build(a, v * 2 + 1, tl, tm);
		build(a, v * 2 + 2, tm, tr);
		t[v] = sum_op(t[v * 2 + 1], t[v * 2 + 2]);
	}

	void build(vector<pii>& a) {
		build(a, 0, 0, size);
	}

	void modify(int v, int tl, int tr, int l, int r, ll val) {
		push(v, tl, tr);
		if (tr <= l || tl >= r) {
			return;
		}

		if (l <= tl && tr <= r) {
			modify_op(t[v].set, val, 1);
			modify_op(t[v].min, val, 1);
			modify_op(t[v].max, val, 1);
			return;
		}

		int tm = (tl + tr) / 2;

		modify(v * 2 + 1, tl, tm, l, r, val);
		modify(v * 2 + 2, tm, tr, l, r, val);

		t[v] = sum_op(t[v * 2 + 1], t[v * 2 + 2]);
	}

	void modify(int l, int r, ll val) {
		modify(0, 0, size, l, r, val);
	}

	node get(int v, int tl, int tr, int l, int r) {
		push(v, tl, tr);
		if (tr <= l || tl >= r) {
			return NEUTRAL_ELEM;
		}

		if (l <= tl && tr <= r) {
			return t[v];
		}

		int tm = (tl + tr) / 2;

		auto g1 = get(v * 2 + 1, tl, tm, l, r);
		auto g2 = get(v * 2 + 2, tm, tr, l, r);

		return sum_op(g1, g2);
	}

	node get(int l, int r) {
		if (l >= r) {
			return ZERO;
		}

		return get(0, 0, size, l, r);
	}
};




void solve() {
	int n, m;
	cin >> n >> m;

	vector<int> k(n + 1);
	vector<pii> left(n + 1);
	vector<pii> right(n + 1);

	for(int i = 1; i <= n; i++){
		cin >> k[i];
		cin >> left[i].first >> left[i].second;
		cin >> right[i].first >> right[i].second;
	}

	for (int i = 0; i <= n; i++) {
		if (left[i].first <= k[i] && k[i] <= left[i].second) {
			inc(i, 1, l);
		}
		if (right[i].first <= k[i] && k[i] <= right[i].second) {
			inc(i, 1, r);
		}
	}

	vector<int> dpl(n + 1), dpr(n + 1);
	vector<int> pl(n + 1), pr(n + 1);

	int last_l = INF, last_r = INF;

	if (left[n].first <= k[n] && k[n] <= left[n].second) {
		dpl[n] = 1;
		last_l = n;
		pl[n] = n + 1;
	}
	if (right[n].first <= k[n] && k[n] <= right[n].second) {
		dpr[n] = 1;
		last_r = n;
		pr[n] = n + 1;
	}
	
	auto st_left = segtree(left);
	auto st_right = segtree(right);

	for (int i = n - 1; i >= 0; i--) {
		int temp_l = last_l, temp_r = last_r;
		
		if (last_r != INF)
		{
			bool ok = (prefix(i + 1, last_r, r) == last_r - (i + 1) + 1);
			
			auto res = st_left.get(i, last_r + 1);
			
			ok &= res.max <= k[i];
			ok &= res.min >= k[i];
			
			if (ok) {
				dpl[i] = 1;
				pl[i] = last_r;
				temp_l = i;
			}
		}

		if (last_l != INF)
		{
			bool ok = (prefix(i + 1, last_l, l) == last_l - (i + 1) + 1);

			auto res = st_right.get(i, last_l + 1);

			ok &= res.max <= k[i];
			ok &= res.min >= k[i];

			if (ok) {
				dpr[i] = 1;
				pr[i] = last_l;
				temp_r = i;
			}
		}
		last_l = temp_l, last_r = temp_r;
	}

	if (dpl[0]) {
		cout << "YES" << en;

		bool first = true;

		int cur = 0;
		bool is_left = true;
		while (cur != n + 1) {
			if (!first) {
				cout << (is_left == 0) << ' ';
			}

			first = 0;

			int nt;
			if (is_left) {
				nt = pl[cur];
			}
			else {
				nt = pr[cur];
			}

			is_left ^= 1;

			for (int i = cur + 1; i < nt; i++) {
				cout << (is_left == 0) << ' ';
			}
			cur = nt;
		}


		return;
	}

	if (dpr[0]) {
		cout << "YES" << en;

		bool first = 1;
		int cur = 0;
		bool is_left = false;
		while (cur != n + 1) {
			if (!first) {
				cout << (is_left == 0) << ' ';
			}

			first = 0;

			int nt;
			if (is_left) {
				nt = pl[cur];
			}
			else {
				nt = pr[cur];
			}

			is_left ^= 1;

			for (int i = cur + 1; i < nt; i++) {
				cout << (is_left == 0) << ' ';
			}
			cur = nt;
		}

		return;
	}

	cout << "NO" << en;
}


int main() {
	srand(time(0));
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


#ifdef _DEBUG	
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif


	int tst = 1;
	//cin >> tst;

	while (tst--)
		solve();
}