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>
#define PI pair<int,int>
using namespace std;
const int maxm=1e5+5;
const int maxd=20;
int la[maxm],ra[maxm];
int lb[maxm],rb[maxm];
PI f[maxm][25];
int pos[2][maxm];
int pre[maxm][2];
int d[maxm][2];
int val[maxm];
int lg2[maxm];
int n,m;
PI merged(PI a,PI b){
    if(a.first==-1)return b;
    if(b.first==-1)return a;
    if(a.first==-2)return {-2,-2};
    if(b.first==-2)return {-2,-2};
    PI ans={max(a.first,b.first),min(a.second,b.second)};
    if(ans.first>ans.second)ans={-2,-2};//无交集
    return ans;
}
void init(){
    lg2[1]=0;
    for(int i=2;i<maxm;i++){
        lg2[i]=lg2[i-1];
        if((i&(i-1))==0)lg2[i]++;
    }
}
PI ask(int l,int r){
    int k=lg2[r-l+1];
    return merged(f[l][k],f[r-(1<<k)+1][k]);
}
void build(int* l,int* r,int* pos){
    for(int i=0;i<maxm;i++){
        for(int j=0;j<25;j++){
            f[i][j]={-1,-1};
        }
    }
    for(int i=1;i<=n;i++){
        f[i][0]={l[i],r[i]};
    }
        for(int j=1;j<=maxd;j++){
            for(int i=1;i+(1<<j)-1<=n;i++){
                f[i][j]=merged(f[i][j-1],f[i+(1<<(j-1))][j-1]);
            }
        }
    for(int i=1;i<=n;i++){
        int ans=0;
        int l=1,r=n-i+1;
        while(l<=r){
            int mid=(l+r)/2;
            PI x=ask(i,i+mid-1);
            if(x.first<=val[i]&&x.second>=val[i]){
                ans=mid,l=mid+1;
            }else{
                r=mid-1;
            }
        }
        pos[i]=i+ans-1;
    }
}
void dfs(int i,int j){
    if(i!=1){
        dfs(i-1,pre[i][j]);
    }
    printf("%d ",j);
}
void solve(){
    init();
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d%d%d",&val[i],&la[i],&ra[i],&lb[i],&rb[i]);
    }
    build(la,ra,pos[0]);
    build(lb,rb,pos[1]);
    PI last={0,1e9};
    for(int i=1;i<=n;i++){
        last=merged(last,{la[i],ra[i]});
        if(last.first<=0&&last.second>=0){
            d[1][1]=i;
        }else break;
    }
    last={0,1e9};
    for(int i=1;i<=n;i++){
        last=merged(last,{lb[i],rb[i]});
        if(last.first<=0&&last.second>=0){
            d[1][0]=i;
        }else break;
    }
    for(int i=2;i<=n;i++){
        for(int j=0;j<2;j++){//枚举当前状态
            for(int last=0;last<2;last++){//枚举上一张卡片的位置
                int p1=pos[last][i-1];
                int p2=d[i-1][last];
                if(j==last){
                    if(p1<i-1)continue;
                    if(p2>=d[i][j]){
                        d[i][j]=p2;
                        pre[i][j]=last;
                    }
                }else{//j!=last
                    if(p2<i-1)continue;
                    if(p1>=d[i][j]){
                        d[i][j]=p1;
                        pre[i][j]=last;
                    }
                }
            }
        }
    }
    for(int j=0;j<2;j++){
        int p1=pos[j][n];
        int p2=d[n][j];
        if(p1>=n&&p2>=n){
            puts("YES");
            dfs(n,j);
            return ;
        }
    }
    puts("NO");
}
signed main(){
    solve();
    return 0;
}