We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value should be equal to qi.
Your task is to find any interesting array of n elements or state that such array doesn't exist.
Expression x&y means the bitwise AND of numbers x and y. In programming languages C++, Java and Python this operation is represented as "&", in Pascal — as "and".
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits.
Each of the next m lines contains three integers li, ri, qi (1 ≤ li ≤ ri ≤ n, 0 ≤ qi < 230) describing the i-th limit.
If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1], a[2], ..., a[n](0 ≤ a[i] < 230) decribing the interesting array. If there are multiple answers, print any of them.
If the interesting array doesn't exist, print "NO" (without the quotes) in the single line.
3 1 1 3 3
YES 3 3 3
3 2 1 3 3 1 3 2
NO
#include
#include
#include
#include
#include
#include
using namespace std;
#define lson l,m,o<<1
#define rson m+1,r,o<<1|1
const int MAXN = 100005;
const int INF = ~0U>>1;
int is[MAXN<<2];
int laz[MAXN<<2];
void build()
{
memset(is,0,sizeof(is));
memset(laz,0,sizeof(laz));
}
void pushdown(int o)
{
if(laz[o]){
laz[o<<1]|=laz[o];
laz[o<<1|1]|=laz[o];
is[o<<1]|=laz[o];
is[o<<1|1]|=laz[o];
laz[o]=0;
}
}
void update(int l,int r,int o,int L,int R,int q)
{
if(L<=l&&r<=R){
is[o]|=q;
laz[o]|=q;
return;
}
int m=l+r>>1;
pushdown(o);
if(L<=m)update(lson,L,R,q);
if(m>1;
pushdown(o);
repair(lson);
repair(rson);
pushup(o);
}
int query(int l,int r,int o,int L,int R)
{
if(L<=l&&r<=R){
return is[o];
}
int m=l+r>>1;
int res=INF;
if(L<=m)res=res&query(lson,L,R);
if(m>1;
pushdown(o);
print(lson);
print(rson);
}
int l[MAXN],r[MAXN],q[MAXN];
int main()
{
int n,m;
scanf("%d%d",&n,&m);
build();
for(int i=0;i