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 <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m,a[100011],l1[100011],r1[100011],l2[100011],r2[100011],dpl[100011],dpr[100011],lg[100011],gol[100011],gor[100011];
int mx1[100011][21],mn1[100011][21],mx2[100011][21],mn2[100011][21];bool pthl[100011],pthr[100011],res[100011];
int qmx1(int l,int r){int logl=lg[r-l+1];return max(mx1[l][logl],mx1[r-(1<<logl)+1][logl]);}
int qmn1(int l,int r){int logl=lg[r-l+1];return min(mn1[l][logl],mn1[r-(1<<logl)+1][logl]);}
int qmx2(int l,int r){int logl=lg[r-l+1];return max(mx2[l][logl],mx2[r-(1<<logl)+1][logl]);}
int qmn2(int l,int r){int logl=lg[r-l+1];return min(mn2[l][logl],mn2[r-(1<<logl)+1][logl]);}
int main()
{
	scanf("%d%d",&n,&m);for(int i=1;i<=n;++i)scanf("%d%d%d%d%d",a+i,l1+i,r1+i,l2+i,r2+i);
	lg[0]=-2;for(int i=0;i<=n+1;++i)mx1[i][0]=l1[i],mn1[i][0]=r1[i],mx2[i][0]=l2[i],mn2[i][0]=r2[i],lg[i]=lg[i>>1]+1;
	for(int i=1;i<=20;++i)
	{
		for(int j=0;j+(1<<i)-1<=n;++j)
		{
			mn1[j][i]=min(mn1[j][i-1],mn1[j+(1<<i-1)][i-1]);
			mx1[j][i]=max(mx1[j][i-1],mx1[j+(1<<i-1)][i-1]);
			mn2[j][i]=min(mn2[j][i-1],mn2[j+(1<<i-1)][i-1]);
			mx2[j][i]=max(mx2[j][i-1],mx2[j+(1<<i-1)][i-1]);
		}
	}
	memset(gol,0x3f,sizeof(gol));memset(gor,0x3f,sizeof(gor));
	for(int i=0;i<=n;++i)
	{
		int l,r,ans;
		l=i;r=n;ans=-1;
		while(l<=r)
		{
			int mid=l+r>>1;
			if(qmx1(i,mid)<=a[i])ans=mid,l=mid+1;else r=mid-1;
		}
		gol[i]=min(gol[i],ans);
		l=i;r=n;ans=-1;
		while(l<=r)
		{
			int mid=l+r>>1;
			if(qmn1(i,mid)>=a[i])ans=mid,l=mid+1;else r=mid-1;
		}
		gol[i]=min(gol[i],ans);
		l=i;r=n;ans=-1;
		while(l<=r)
		{
			int mid=l+r>>1;
			if(qmx2(i,mid)<=a[i])ans=mid,l=mid+1;else r=mid-1;
		}
		gor[i]=min(gor[i],ans);
		l=i;r=n;ans=-1;
		while(l<=r)
		{
			int mid=l+r>>1;
			if(qmn2(i,mid)>=a[i])ans=mid,l=mid+1;else r=mid-1;
		}
		gor[i]=min(gor[i],ans);
	}
	memset(dpl,-1,sizeof(dpl));memset(dpr,-1,sizeof(dpr));
	dpl[0]=gor[0];dpr[0]=gol[0];
	for(int i=0;i<n;++i)
	{
		if(dpl[i]>0)
		{
			if(gol[i+1]>=i+1&&dpl[i]>=i+1)if(dpl[i+1]<dpl[i])dpl[i+1]=dpl[i],pthl[i+1]=0;
			if(gor[i+1]>=i+1&&gol[i]>=i+1)if(dpr[i+1]<gol[i])dpr[i+1]=gol[i],pthr[i+1]=0;
		}
		if(dpr[i]>0)
		{
			if(gor[i+1]>=i+1&&dpr[i]>=i+1)if(dpr[i+1]<dpr[i])dpr[i+1]=dpr[i],pthr[i+1]=1;
			if(gol[i+1]>=i+1&&gor[i]>=i+1)if(dpl[i+1]<gor[i])dpl[i+1]=gor[i],pthl[i+1]=1;
		}
	}
	if(dpl[n]==-1&&dpr[n]==-1)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");bool lr=(dpl[n]==-1);
		for(int i=n;i;--i)
		{
			if(lr)res[i]=lr,lr=pthr[i];
			else res[i]=lr,lr=pthl[i];
		}
		for(int i=1;i<=n;++i)printf("%d ",res[i]);putchar(10);
	}
	return 0;
}