#include<bits/stdc++.h>
using namespace std;
int c[n+1];
int b[1000000];
int get(int p)
{
    if(c[p]==p)
    return p;
    return c[p]=get(c[p]);
}
int main()
{
    int n,m;
    cin>>n>>m;
    int i,j,l,r,x;

    for(i=1;i<=n;i++)
    c[i]=i;
    int p;
    for(i=0;i<m;i++)
{
    cin>>l>>r>>x;
    p=get(l);
    while(p<=r)
    {
if(p==x)
p++;
else
{
b[p]=x;
c[p]=p+1;
}
p=get(p);

    }
}
    for(i=1;i<=n;i++)
    cout<<b[i];
}


#include<bits/stdc++.h>
using namespace std;
int c[1000000];
int b[1000000];
int a[1000000][3];
int get(int p,int n)
{if(p>n)
return p;
    if(c[p]==p)
    return p;
    return c[p]=get(c[p],n);
}
int main()
{
    int n,m;
    cin>>n>>m;
    int i,j,l,r,x;
    for(i=0;i<m;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    for(i=1;i<=n;i++)
    c[i]=i;
    int p;
    for(i=0;i<m;i++)
{
    l=a[i][0];
    r=a[i][1];
    x=a[i][2];
    p=get(l,n);
    while(p<=r)
    {
if(p==x)
p++;
else
{
b[p]=x;
c[p]=p+1;
}

p=get(p,n);

    }
}
    for(i=1;i<=n;i++)
    cout<<b[i]<<" ";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int c[1000000];
int b[1000000];
int get(int p)
{
    if(c[p]==p)
    return p;
    return c[p]=get(c[p]);
}
int main()
{
    int n,m;
    cin>>n>>m;
    int i,j,l,r,x;

    for(i=1;i<=n;i++)
    c[i]=i;
    int p;
    for(i=0;i<m;i++)
{
    cin>>l>>r>>x;
    p=get(l);
    while(p<=r)
    {
if(p==x)
p++;
else
{
b[p]=x;
c[p]=p+1;
}
p=get(p);

    }
}
    for(i=1;i<=n;i++)
    cout<<b[i];
}


#include<bits/stdc++.h>
using namespace std;
int a[1000000][3];
int b[1000000];
int main()
{
    int n,m;
    cin>>n>>m;
    int i,j;
    map<int,int> mm;
for(i=1;i<=n;i++)
mm[i]=1;
    for(i=0;i<m;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];

    }

for(i=0;i<m;i++)
{
auto it=mm.lower_bound(a[i][0]);
while(it!=mm.end()&&it->first<=a[i][1])
{
    if(it->first==a[i][2])
{
    it++;
    continue;
}
    b[it->first]=a[i][2];
    auto it1=it;
    it++;
mm.erase(it1);

}

}
b[a[m-1][2]]=0;
for(i=1;i<=n;i++)
cout<<b[i]<<" ";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[1000000][3];
int b[1000000];
int main()
{
    int n,m;
    cin>>n>>m;
    int i,j;
    map<int,int> mm;
for(i=1;i<=n;i++)
mm[i]=1;
    for(i=0;i<m;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];

    }

for(i=0;i<mm;i++)
{
auto it=mm.lower_bound(a[i][0]);
while(it!=mm.end()&&it->first<=a[i][1])
{
    b[it->first]=a[i][2];
    auto it1=it;
    it++;
mm.erase(it);

}

}
b[a[m-1][2]]=0;
for(i=1;i<=n;i++)
cout<<b[i]<<" ";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int c[1000000];
int b[1000000];
int get(int p)
{
    if(c[p]==p)
    return p;
    return c[p]=get(c[p]);
}
int main()
{
    int n,m;
    cin>>n>>m;
    int i,j,l,r,x;

    for(i=1;i<=n;i++)
    c[i]=i;
    int p;
    for(i=0;i<m;i++)
{
    cin>>l>>r>>x;
    p=get(l);
    while(p<=r)
    {
if(p==x)
p++;
else
{
b[p]=x;
c[p]=p+1;
}
p=get(p);

    }
}
    for(i=1;i<=n;i++)
    cout<<b[i];

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[1000000][3];
int b[1000000];
int main()
{
    int n,m;
    cin>>n>>m;
    int i,j;
    map<int,int> mm;
for(i=1;i<=n;i++)
mm[i]=1;
    for(i=0;i<m;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];

    }

for(i=0;i<m;i++)
{
auto it=mm.lower_bound(a[i][0]);
while(it!=mm.end()&&it->first<=a[i][1])
{
    b[it->first]=a[i][2];
    auto it1=it;
    it++;
mm.erase(it);

}

}
b[a[m-1][2]]=0;
for(i=1;i<=n;i++)
cout<<b[i]<<" ";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[1000000][3];
int b[1000000];
int main()
{
    int n,m;
    cin>>n>>m;
    int i,j;
    map<int,int> m;
for(i=0;i<n;i++)
m[i]=1;
    for(i=0;i<m;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];

    }

for(i=0;i<m;i++)
{
auto it=m.lower_bound(a[i][0]);
while(it!=m.end()&&it->first<=a[i][1])
{
    b[it->first]=a[i][2];
    auto it1=it;
    it++;
m.erase(it);

}

}
b[a[m-1][2]]=0;
for(i=1;i<=n;i++)
cout<<b[i]<<" ";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int c[1000000];
int b[1000000];
int a[1000000][3];
int get(int p,int n)
{if(p>n)
return p;
    if(c[p]==p)
    return p;
    return c[p]=get(c[p],n);
}
int main()
{
    int n,m;
    cin>>n>>m;
    int i,j,l,r,x;

    for(i=1;i<=n;i++)
    c[i]=i;
    int p;
    for(i=0;i<m;i++)
{
    cin>>l>>r>>x;
    p=get(l,n);
    while(p<=r)
    {
if(p==x)
p++;
else
{
b[p]=x;
c[p]=p+1;
}

p=get(p,n);

    }
}
    for(i=1;i<=n;i++)
    cout<<b[i]<<" ";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
struct node{
    ll id,k;
}T[5123456];
void update(ll n,ll b,ll e,ll x,ll y,ll val){
    if(x>y)return;
    if(b>y || e<x)return;
    if(b>=x&& e<=y && !T[n].k){
        T[n].k=1LL;
        T[n].id=val;
        return;
    }
    update(n*2,b,(b+e)/2,x,y,val);
    update(n*2+1,(b+e)/2+1,e,x,y,val);
    T[n].k=(T[n*2].k+T[n*2+1].k);
}
ll query(ll n,ll b,ll e,ll x,ll val){
    if(b>x || e<x)return 0LL;
    if(b==e)return val;
    return max(query(n*2,b,(b+e)/2,x,max(val,T[n*2].id)),query(n*2+1,(b+e)/2+1,e,x,max(val,T[n*2+1].id)));
}
int main(){
    ll n,q;
    scanf("%lld%lld",&n,&q);
    while(q--){
        ll x,y,z;
        scanf("%lld%lld%lld",&x,&y,&z);
        update(1,1,n,x,z-1,z);
        update(1,1,n,z+1,y,z);
    }
    for(ll i=1LL;i<=n;i++)printf("%lld ",query(1,1,n,i,T[1].id));
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
struct node{
    ll id,k;
}T[3123456];
void update(ll n,ll b,ll e,ll x,ll y,ll val){
    if(x>y)return;
    if(b>y || e<x)return;
    if(b>=x&& e<=y && !T[n].k){
        T[n].k=1LL;
        T[n].id=val;
        return;
    }
    update(n*2,b,(b+e)/2,x,y,val);
    update(n*2+1,(b+e)/2+1,e,x,y,val);
    T[n].k=(T[n*2].k+T[n*2+1].k);
}
ll query(ll n,ll b,ll e,ll x,ll val){
    if(b>x || e<x)return 0LL;
    if(b==e)return val;
    return max(query(n*2,b,(b+e)/2,x,max(val,T[n*2].id)),query(n*2+1,(b+e)/2+1,e,x,max(val,T[n*2+1].id)));
}
int main(){
    ll n,q;
    scanf("%lld%lld",&n,&q);
    while(q--){
        ll x,y,z;
        scanf("%lld%lld%lld",&x,&y,&z);
        update(1,1,n,x,z-1,z);
        update(1,1,n,z+1,y,z);
    }
    for(ll i=1LL;i<=n;i++)printf("%lld ",query(1,1,n,i,T[1].id));
}


#include<bits/stdc++.h>
using namespace std;
const int N=3123456;
struct node{
    int id,k;
};
node T[N];
void update(int n,int b,int e,int i,int j,int val){
    if(b>j || e<i)return;
    if(b>=i && e<=j){
      //  cout<<b<<' '<<e<<endl;
        if(T[n].k==1){
            update(n*2,b,(b+e)/2,i,j,val);
            update(n*2+1,(b+e)/2+1,e,i,j,val);
        }else{
            T[n].k=1;
            T[n].id=val;
        }
        if(b==e)return;
    //    cout<<T[n].k<<' '<<T[n].id<<endl;
        return;
    }
    update(n*2,b,(b+e)/2,i,j,val);
    update(n*2+1,(b+e)/2+1,e,i,j,val);
    T[n].k=(T[n*2].k|T[n*2+1].k);
}
int query(int n,int b,int e,int x,int val){
    if(b>x || e<x)return 0;
    if(b==e){
        return max(val,T[n].id);
    }
    return max(query(n*2,b,(b+e)/2,x,max(val,T[n].id)),query(n*2+1,(b+e)/2+1,e,x,max(val,T[n].id)));
}
int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    while(q--){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        if(x!=z)update(1,1,n,x,z-1,z);
        if(y!=z)update(1,1,n,z+1,y,z);
    }
    //if(n==300000)cout<<"masum"<<endl;
    for(int i=1;i<=n;i++){
        printf("%d ",query(1,1,n,i,0));
    }
}


#include<bits/stdc++.h>
using namespace std;

/************************Start Of Template*************************/

/******** Mahin Shefat - GhOstMan *************/

#define     pb              push_back
#define     popb            pop_back
#define     ll              long long int
#define     ull             unsigned long long int
#define     max3(a,b,c)     max(a,max(b,c))
#define     max4(a,b,c,d)   max(max3(a,b,c),d)
#define     min3(a,b,c)     min(a,min(b,c))
#define     min4(a,b,c,d)   min(a,min3(b,c,d))
#define     MOD             1000000009
#define     f               first
#define     s               second
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     mp              make_pair
#define     check           printf("check")
#define     sqr(x)          (x)*(x)
#define     all(v)          v.begin(),v.end()
#define     fast            ios_base::sync_with_stdio(0);cin.tie(0)
#define     pii             pair<int,int>
#define     Pair            pair<ll,ll>
#define     MAX             1000000000000000000
#define     MIN             -100000000000014
#define     Fread           freopen("input.txt","r",stdin);
#define     Fwrite          freopen("output.txt","w",stdout);

/************************End Of Template*************************/
struct node
{
	int idx , rng;
}tree[3000006];
#define mx 1000000
void upd(int node , int low , int high , int l , int r , int id){
	if(l > r) return;
	if(low > r || high < l) return;
	if(tree[node].rng == (high - low + 1)) return;
	if(low >= l && high <= r && tree[node].rng == 0){
		tree[node].idx = id;
		tree[node].rng = high - low + 1;
		return;
	}
	int mid = (low + high) / 2;
	upd(2 * node , low , mid , l , r , id);
	upd(2 * node + 1 , mid + 1 , high , l , r , id);
	tree[node].rng = tree[2 * node].rng + tree[2 * node + 1].rng;
}
void go(int node , int low , int high){
	if(low == high){
		cout << tree[node].idx << " ";
		return;
	}
	if(tree[node].idx != 0) {
		tree[2 * node].idx = tree[node].idx;
		tree[2 * node + 1].idx = tree[node].idx;
	}
	int mid = (low + high) / 2;
	go(2 * node , low , mid);
	go(2 * node + 1 , mid + 1 , high);
}
int main()
{
	int n , m;
	cin >> n >> m;
	for(int i = 1; i <= mx ; i++) {
		tree[i].idx = 0;
		tree[i].rng = 0;
	}
	for(int i = 1; i <= m; i++){
		int l , r , id;
		cin >> l >> r >> id ;
		upd(1 , 1 , n , l , id - 1 , id);
		upd(1 , 1 , n , id + 1 , r , id);
	}
	go(1 , 1 , n);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=31123456;
struct node{
    int id,k;
};
node T[N];
void update(int n,int b,int e,int i,int j,int val){
    if(b>j || e<i)return;
    if(b>=i && e<=j){
      //  cout<<b<<' '<<e<<endl;
        if(T[n].k){
            update(n*2,b,(b+e)/2,i,j,val);
            update(n*2+1,(b+e)/2+1,e,i,j,val);
        }else{
            T[n].k=1;
            T[n].id=val;
        }
        if(b==e)return;
    //    cout<<T[n].k<<' '<<T[n].id<<endl;
        return;
    }
    update(n*2,b,(b+e)/2,i,j,val);
    update(n*2+1,(b+e)/2+1,e,i,j,val);
    T[n].k=(T[n*2].k+T[n*2+1].k);
}
int query(int n,int b,int e,int x,int val){
    if(b>x || e<x)return 0;
    if(b==e){
        return val;
    }
    return max(query(n*2,b,(b+e)/2,x,max(val,T[n*2].id)),query(n*2+1,(b+e)/2+1,e,x,max(val,T[n*2+1].id)));
}
int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    while(q--){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        if(x!=z)update(1,1,n,x,z-1,z);
        if(y!=z)update(1,1,n,z+1,y,z);
    }
    //if(n==300000)cout<<"masum"<<endl;
    for(int i=1;i<=n;i++){
        printf("%d ",query(1,1,n,i,T[1].id));
    }
}


#include<bits/stdc++.h>
using namespace std;

/************************Start Of Template*************************/

/******** Mahin Shefat - GhOstMan *************/

#define     pb              push_back
#define     popb            pop_back
#define     ll              long long int
#define     ull             unsigned long long int
#define     max3(a,b,c)     max(a,max(b,c))
#define     max4(a,b,c,d)   max(max3(a,b,c),d)
#define     min3(a,b,c)     min(a,min(b,c))
#define     min4(a,b,c,d)   min(a,min3(b,c,d))
#define     MOD             1000000009
#define     f               first
#define     s               second
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     mp              make_pair
#define     check           printf("check")
#define     sqr(x)          (x)*(x)
#define     all(v)          v.begin(),v.end()
#define     fast            ios_base::sync_with_stdio(0);cin.tie(0)
#define     pii             pair<int,int>
#define     Pair            pair<ll,ll>
#define     MAX             1000000000000000000
#define     MIN             -100000000000014
#define     Fread           freopen("input.txt","r",stdin);
#define     Fwrite          freopen("output.txt","w",stdout);

/************************End Of Template*************************/
struct node
{
	int idx , rng;
}tree[1000006];
#define mx 1000000
void upd(int node , int low , int high , int l , int r , int id){
	if(l > r) return;
	if(low > r || high < l) return;
	if(tree[node].rng == (high - low + 1)) return;
	if(low >= l && high <= r && tree[node].rng == 0){
		tree[node].idx = id;
		tree[node].rng = high - low + 1;
		return;
	}
	int mid = (low + high) / 2;
	upd(2 * node , low , mid , l , r , id);
	upd(2 * node + 1 , mid + 1 , high , l , r , id);
	tree[node].rng = tree[2 * node].rng + tree[2 * node + 1].rng;
}
void go(int node , int low , int high){
	if(low == high){
		cout << tree[node].idx << " ";
		return;
	}
	if(tree[node].idx != 0) {
		tree[2 * node].idx = tree[node].idx;
		tree[2 * node + 1].idx = tree[node].idx;
	}
	int mid = (low + high) / 2;
	go(2 * node , low , mid);
	go(2 * node + 1 , mid + 1 , high);
}
int main()
{
	int n , m;
	cin >> n >> m;
	for(int i = 1; i <= mx ; i++) {
		tree[i].idx = 0;
		tree[i].rng = 0;
	}
	for(int i = 1; i <= m; i++){
		int l , r , id;
		cin >> l >> r >> id ;
		upd(1 , 1 , n , l , id - 1 , id);
		upd(1 , 1 , n , id + 1 , r , id);
	}
	go(1 , 1 , n);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
struct node{
    ll id,k;
}T[6123456];
void update(ll n,ll b,ll e,ll x,ll y,ll val){
    if(x>y)return;
    if(b>y || e<x)return;
    if(b>=x&& e<=y && !T[n].k){
        T[n].k=1LL;
        T[n].id=val;
        return;
    }
    update(n*2,b,(b+e)/2,x,y,val);
    update(n*2+1,(b+e)/2+1,e,x,y,val);
    T[n].k=(T[n*2].k+T[n*2+1].k);
}
ll query(ll n,ll b,ll e,ll x,ll val){
    if(b>x || e<x)return 0LL;
    if(b==e)return val;
    return max(query(n*2,b,(b+e)/2,x,max(val,T[n*2].id)),query(n*2+1,(b+e)/2+1,e,x,max(val,T[n*2+1].id)));
}
int main(){
    ll n,q;
    scanf("%lld%lld",&n,&q);
    while(q--){
        ll x,y,z;
        scanf("%lld%lld%lld",&x,&y,&z);
        update(1,1,n,x,z-1,z);
        update(1,1,n,z+1,y,z);
    }
    for(ll i=1LL;i<=n;i++)printf("%lld ",query(1,1,n,i,T[1].id));
}


#include<bits/stdc++.h>
using namespace std;
const int N=31123456;
struct node{
    int id,k;
};
node T[N];
void update(int n,int b,int e,int i,int j,int val){
    if(b>j || e<i)return;
    if(b>=i && e<=j){
      //  cout<<b<<' '<<e<<endl;
        if(T[n].k){
            update(n*2,b,(b+e)/2,i,j,val);
            update(n*2+1,(b+e)/2+1,e,i,j,val);
        }else{
            T[n].k=1;
            T[n].id=val;
        }
        if(b==e)return;
    //    cout<<T[n].k<<' '<<T[n].id<<endl;
        return;
    }
    update(n*2,b,(b+e)/2,i,j,val);
    update(n*2+1,(b+e)/2+1,e,i,j,val);
    T[n].k=(T[n*2].k+T[n*2+1].k);
}
int query(int n,int b,int e,int x,int val){
    if(b>x || e<x)return 0;
    if(b==e){
        return max(val,T[n].id);
    }
    return max(query(n*2,b,(b+e)/2,x,max(val,T[n].id)),query(n*2+1,(b+e)/2+1,e,x,max(val,T[n].id)));
}
int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    while(q--){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        if(x!=z)update(1,1,n,x,z-1,z);
        if(y!=z)update(1,1,n,z+1,y,z);
    }
    //if(n==300000)cout<<"masum"<<endl;
    for(int i=1;i<=n;i++){
        printf("%d ",query(1,1,n,i,0));
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
struct node{
    ll id,k;
}T[9123456];
void update(ll n,ll b,ll e,ll x,ll y,ll val){
    if(x>y)return;
    if(b>y || e<x)return;
    if(b>=x&& e<=y && !T[n].k){
        T[n].k=1LL;
        T[n].id=val;
        return;
    }
    update(n*2,b,(b+e)/2,x,y,val);
    update(n*2+1,(b+e)/2+1,e,x,y,val);
    T[n].k=(T[n*2].k+T[n*2+1].k);
}
ll query(ll n,ll b,ll e,ll x,ll val){
    if(b>x || e<x)return 0LL;
    if(b==e)return val;
    return max(query(n*2,b,(b+e)/2,x,max(val,T[n*2].id)),query(n*2+1,(b+e)/2+1,e,x,max(val,T[n*2+1].id)));
}
int main(){
    ll n,q;
    scanf("%lld%lld",&n,&q);
    while(q--){
        ll x,y,z;
        scanf("%lld%lld%lld",&x,&y,&z);
        update(1,1,n,x,z-1,z);
        update(1,1,n,z+1,y,z);
    }
    for(ll i=1LL;i<=n;i++)printf("%lld ",query(1,1,n,i,T[1].id));
}


#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
struct node{
    int id,k;
};
node T[31123456];
void update(int n,int b,int e,int i,int j,int val){
    if(b>j || e<i)return;
    if(b>=i && e<=j){
      //  cout<<b<<' '<<e<<endl;
        if(T[n].k){
            update(n*2,b,(b+e)/2,i,j,val);
            update(n*2+1,(b+e)/2+1,e,i,j,val);
        }else{
            T[n].k=1;
            T[n].id=val;
        }
        if(b==e)return;
    //    cout<<T[n].k<<' '<<T[n].id<<endl;
        return;
    }
    update(n*2,b,(b+e)/2,i,j,val);
    update(n*2+1,(b+e)/2+1,e,i,j,val);
    T[n].k=(T[n*2].k+T[n*2+1].k);
}
int query(int n,int b,int e,int x,int val){
    if(b>x || e<x)return 0;
    if(b==e){
        return val;
    }
    return max(query(n*2,b,(b+e)/2,x,max(val,T[n*2].id)),query(n*2+1,(b+e)/2+1,e,x,max(val,T[n*2+1].id)));
}
int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    while(q--){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        if(x!=z)update(1,1,n,x,z-1,z);
        if(y!=z)update(1,1,n,z+1,y,z);
    }
    //if(n==300000)cout<<"masum"<<endl;
    for(int i=1;i<=n;i++){
        printf("%d ",query(1,1,n,i,T[1].id));
    }
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=3*1000000+5;
int n,m;
int f[maxn];
int getf(int x){return f[x]==x?f[x]:f[x]=getf(f[x]);}
void merge(int u,int v){
    int fu=getf(u),fv=getf(v);
    if(fu>fv) swap(fu,fv);
    f[fu]=fv;
}
int l[maxn],r[maxn],x[maxn];
int ans[maxn];
void out(){
    printf("f:\n");
    for(int i=1;i<=n;i++){
        printf("f[%d]=%d\n",i,f[i]);
    }puts("");
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&l[i],&r[i],&x[i]);
    }
    for(int i=1;i<=n+1;i++) f[i]=i;
    for(int i=1;i<=m;i++){
        for(int j=getf(l[i]);j<=r[i];j=getf(j+1)){
            if(j>r[i]) break;
            ans[j]=x[i];
        }
        if(l[i]<=x[i]-1) f[l[i]]=x[i];
        if(x[i]+1<=r[i]) f[x[i]+1]=r[i]+1;
        //out();
        /*printf("ans:\n");
        for(int j=1;j<=n;j++) printf("ans[%d]=%d\n",j,ans[j]);
        puts("");*/
        if(i==m) ans[x[i]]=0;
    }
    for(int i=1;i<=n;i++){
        printf("%d%c",ans[i],i==n?'\n':' ');
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=3*100000+5;
int n,m;
int f[maxn];
int getf(int x){return f[x]==x?f[x]:f[x]=getf(f[x]);}
void merge(int u,int v){
    int fu=getf(u),fv=getf(v);
    if(fu>fv) swap(fu,fv);
    f[fu]=fv;
}
int l[maxn],r[maxn],x[maxn];
int ans[maxn];
void out(){
    printf("f:\n");
    for(int i=1;i<=n;i++){
        printf("f[%d]=%d\n",i,f[i]);
    }puts("");
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&l[i],&r[i],&x[i]);
    }
    for(int i=1;i<=n;i++) f[i]=i;
    f[n+1]=n+1;
    int tmp=0;
    for(int i=1;i<=m;i++){
        for(int j=getf(l[i]);j<=r[i];j=getf(j+1)){
            ans[j]=x[i];
        }
        f[l[i]]=x[i];
        f[x[i]+1]=r[i]+1;
        //out();
        /*printf("ans:\n");
        for(int j=1;j<=n;j++) printf("ans[%d]=%d\n",j,ans[j]);
        puts("");*/
        if(i==m) ans[x[i]]=0;
    }
    for(int i=1;i<=n;i++){
        printf("%d%c",ans[i],i==n?'\n':' ');
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=3*1000000+5;
int n,m;
int f[maxn];
int getf(int x){return f[x]==x?f[x]:f[x]=getf(f[x]);}
int l[maxn],r[maxn],x[maxn];
int ans[maxn];
void out(){
    printf("f:\n");
    for(int i=1;i<=n;i++){
        printf("f[%d]=%d\n",i,f[i]);
    }puts("");
}
void merge(int u,int v){
    int fu=getf(u),fv=getf(v);
    if(fu==fv) return;
    if(fu>fv) swap(fu,fv);
    f[fu]=fv;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&l[i],&r[i],&x[i]);
    }
    for(int i=1;i<=n+1;i++) f[i]=i;
    for(int i=1;i<=m;i++){
        for(int j=getf(l[i]);j<=r[i];j=getf(j+1)){
            if(j>r[i]) break;
            ans[j]=x[i];
            if(j!=x[i]) f[j]=j+1;
        }
        //out();
        /*printf("ans:\n");
        for(int j=1;j<=n;j++) printf("ans[%d]=%d\n",j,ans[j]);
        puts("");*/
        if(i==m) ans[x[i]]=0;
    }
    for(int i=1;i<=n;i++){
        printf("%d%c",ans[i],i==n?'\n':' ');
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=3*1000000+5;
int n,m;
int f[maxn];
int getf(int x){return f[x]==x?f[x]:f[x]=getf(f[x]);}
int l[maxn],r[maxn],x[maxn];
int ans[maxn];
void out(){
    printf("f:\n");
    for(int i=1;i<=n;i++){
        printf("f[%d]=%d\n",i,f[i]);
    }puts("");
}
void merge(int u,int v){
    int fu=getf(u),fv=getf(v);
    if(fu==fv) return;
    if(fu>fv) swap(fu,fv);
    f[fu]=fv;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&l[i],&r[i],&x[i]);
    }
    for(int i=1;i<=n+1;i++) f[i]=i;
    for(int i=1;i<=m;i++){
        for(int j=getf(l[i]);j<=r[i];j=getf(j+1)){
            if(j>r[i]) break;
            ans[j]=x[i];
        }
        if(l[i]<=x[i]-1) merge(l[i],x[i]);
        if(x[i]+1<=r[i])  merge(x[i]+1,r[i]+1);
        //out();
        /*printf("ans:\n");
        for(int j=1;j<=n;j++) printf("ans[%d]=%d\n",j,ans[j]);
        puts("");*/
        if(i==m) ans[x[i]]=0;
    }
    for(int i=1;i<=n;i++){
        printf("%d%c",ans[i],i==n?'\n':' ');
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=3*100000+5;
int n,m;
int f[maxn];
int getf(int x){return f[x]==x?f[x]:f[x]=getf(f[x]);}
void merge(int u,int v){
    int fu=getf(u),fv=getf(v);
    if(fu>fv) swap(fu,fv);
    f[fu]=fv;
}
int l[maxn],r[maxn],x[maxn];
int ans[maxn];
void out(){
    printf("f:\n");
    for(int i=1;i<=n;i++){
        printf("f[%d]=%d\n",i,f[i]);
    }puts("");
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&l[i],&r[i],&x[i]);
    }
    for(int i=1;i<=n+1;i++) f[i]=i;
    for(int i=1;i<=m;i++){
        for(int j=getf(l[i]);j<=r[i];j=getf(j+1)){
            if(j>r[i]) break;
            ans[j]=x[i];
        }
        f[l[i]]=x[i];
        f[x[i]+1]=r[i]+1;
        //out();
        /*printf("ans:\n");
        for(int j=1;j<=n;j++) printf("ans[%d]=%d\n",j,ans[j]);
        puts("");*/
        if(i==m) ans[x[i]]=0;
    }
    for(int i=1;i<=n;i++){
        printf("%d%c",ans[i],i==n?'\n':' ');
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=3*100000+5;
int n,m;
int f[maxn];
int getf(int x){return f[x]==x?f[x]:f[x]=getf(f[x]);}
void merge(int u,int v){
    int fu=getf(u),fv=getf(v);
    if(fu>fv) swap(fu,fv);
    f[fu]=fv;
}
int l[maxn],r[maxn],x[maxn];
int ans[maxn];
void update(int l,int r,int fa)
{
    //printf("l=%d r=%d fa=%d\n",l,r,fa);
    if(r<l) return;
    for(int i=l;i<=r;i++)
        merge(i,fa);
}
void out(){
    printf("f:\n");
    for(int i=1;i<=n;i++){
        printf("f[%d]=%d\n",i,f[i]);
    }puts("");
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&l[i],&r[i],&x[i]);
    }
    for(int i=1;i<=n+1;i++) f[i]=i;
    int tmp=0;
    for(int i=1;i<=m;i++){
        //printf("i=%d\n",i);
        for(int j=getf(l[i]);j<=r[i];){
            //printf("%d\n",getf(l[i]));
            //printf("j=%d\n",j);
            ans[j]=x[i];
            tmp=getf(j);
            j=getf(j+1);
        }
        update(l[i],x[i]-1,x[i]);
        update(x[i]+1,r[i],r[i]+1);
        //out();
        /*printf("ans:\n");
        for(int j=1;j<=n;j++) printf("ans[%d]=%d\n",j,ans[j]);
        puts("");*/
        if(i==m) ans[x[i]]=0;
    }
    for(int i=1;i<=n;i++){
        printf("%d%c",ans[i],i==n?'\n':' ');
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=3*1000000+5;
int n,m;
int f[maxn];
int getf(int x){return f[x]==x?f[x]:f[x]=getf(f[x]);}
void merge(int u,int v){
    int fu=getf(u),fv=getf(v);
    if(fu>fv) swap(fu,fv);
    f[fu]=fv;
}
int l[maxn],r[maxn],x[maxn];
int ans[maxn];
void out(){
    printf("f:\n");
    for(int i=1;i<=n;i++){
        printf("f[%d]=%d\n",i,f[i]);
    }puts("");
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&l[i],&r[i],&x[i]);
    }
    for(int i=1;i<=n+1;i++) f[i]=i;
    for(int i=1;i<=m;i++){
        for(int j=getf(l[i]);j<=r[i];j=getf(j+1)){
            if(j>r[i]) break;
            ans[j]=x[i];
        }
        if(l[i]<=x[i]-1) f[getf(l[i])]=getf(x[i]);
        if(x[i]+1<=r[i]) f[getf(x[i]+1)]=getf(r[i]+1);
        //out();
        /*printf("ans:\n");
        for(int j=1;j<=n;j++) printf("ans[%d]=%d\n",j,ans[j]);
        puts("");*/
        if(i==m) ans[x[i]]=0;
    }
    for(int i=1;i<=n;i++){
        printf("%d%c",ans[i],i==n?'\n':' ');
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=3*1000000+5;
int n,m;
int f[maxn];
int getf(int x){return f[x]==x?f[x]:f[x]=getf(f[x]);}
void merge(int u,int v){
    int fu=getf(u),fv=getf(v);
    if(fu>fv) swap(fu,fv);
    f[fu]=fv;
}
int l[maxn],r[maxn],x[maxn];
int ans[maxn];
void out(){
    printf("f:\n");
    for(int i=1;i<=n;i++){
        printf("f[%d]=%d\n",i,f[i]);
    }puts("");
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&l[i],&r[i],&x[i]);
    }
    for(int i=1;i<=n+1;i++) f[i]=i;
    for(int i=1;i<=m;i++){
        for(int j=getf(l[i]);j<=r[i];j=getf(j+1)){
            if(j>r[i]) break;
            ans[j]=x[i];
        }
        f[l[i]]=x[i];
        f[x[i]+1]=r[i]+1;
        //out();
        /*printf("ans:\n");
        for(int j=1;j<=n;j++) printf("ans[%d]=%d\n",j,ans[j]);
        puts("");*/
        if(i==m) ans[x[i]]=0;
    }
    for(int i=1;i<=n;i++){
        printf("%d%c",ans[i],i==n?'\n':' ');
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long lol;
int main(){
    set<int>st;
    int n,m,s,e,w,parent[300005];
    set<int>::iterator sit,eit,tmp;
    cin>>n>>m;
    for(int i=0;i<=n;i++)st.insert(i);
    while(m--){
        cin>>s>>e>>w;
        tmp=st.upper_bound(s);
        eit=st.upper_bound(e);
        tmp--;
        if(*tmp<s)tmp++;
        sit=tmp;
        while(sit!=eit){
            parent[*sit]=w;
            sit++;
        }
        st.erase(tmp,eit);
        st.insert(w);
    }
    for(auto it=st.begin();it!=st.end();it++)parent[*it]=0;
    for(int i=1;i<=n;i++)
        cout<<parent[i]<<" ";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long lol;
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int main(){
    fast_in_out();
    set<int>st;
    int n,m,s,e,w,parent[300005];
    set<int>::iterator sit,eit,tmp;
    cin>>n>>m;
    for(int i=0;i<=n;i++)st.insert(i);
    while(m--){
        cin>>s>>e>>w;
        tmp=st.upper_bound(s);
        eit=st.upper_bound(e);
        tmp--;
        if(*tmp<s)tmp++;
        sit=tmp;
        while(sit!=eit){
            parent[*sit]=w;
            sit++;
        }
        st.erase(tmp,eit);
        st.insert(w);
    }
    for(auto it=st.begin();it!=st.end();it++)parent[*it]=0;
    for(int i=1;i<=n;i++)
        cout<<parent[i]<<" ";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long lol;
int main(){
    set<int>st;
    int n,m,s,e,w,parent[300005];
    set<int>::iterator sit,eit,tmp;
    cin>>n>>m;
    iota(parent,parent+n+1,0);
    for(int i=0;i<=n;i++)st.insert(i);
    while(m--){
        cin>>s>>e>>w;
        tmp=upper_bound(st.begin(),st.end(),s);
        eit=upper_bound(st.begin(),st.end(),e);
        tmp--;
        if(*tmp<s)tmp++;
        sit=tmp;
        while(sit!=eit){
            parent[*sit]=w;
            sit++;
        }
        st.erase(tmp,eit);
        st.insert(w);
    }
    for(auto it=st.begin();it!=st.end();it++)parent[*it]=0;
    for(int i=1;i<=n;i++)
        cout<<parent[i]<<" ";
}


#include <bits/stdc++.h>
using namespace std;

int movei[] = {0, 0, 1, -1, 1, 1, -1, -1};
int movej[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int S = 1e6+1;
int res[S];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int n,m;
    cin >> n >> m;
    set<int> kn;
    for(int i=1; i<=n; ++i) kn.insert(i);
    while(m--) {
        int l, r, x;
        cin >> l >> r >> x;
        auto i = kn.lower_bound(l);
        auto j = kn.lower_bound(r);
        auto end = kn.lower_bound(r);

        if (j == kn.end() || (*j) != r) j--;
        else end++;
        for (auto it = i; it != end;) {
            if (*it != x){
                res[*it] = x;
                it = kn.erase(it);
            }
            else it++;
        }
    }
    for(int i=1; i<=n; ++i) cout << res[i] << " ";
}


#include <bits/stdc++.h>
using namespace std;

int movei[] = {0, 0, 1, -1, 1, 1, -1, -1};
int movej[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int S = 1e6+1;
int nxt[S], res[S];
int findnext(int knight){
    if(nxt[knight] == knight) return knight;
    else return nxt[knight] = findnext(nxt[knight]);
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int n,m;
    cin >> n >> m;
    for(int i = 1; i<=n+1; ++i) nxt[i] = i;
    while(m--){
        int l, r, x;
        cin >> l >> r >> x;
        int i = findnext(l);
        while(i<=r){
            if(i == x) i++;
            else{
                res[i] = x;
                nxt[i] = findnext(i+1);
            }
            i = findnext(i);
        }
    }
    for(int i=1; i<=n; ++i) cout << res[i] << " ";
}


#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<long,long>
#define vi          vector<long long>
#define vii         vector<pii>
#define mi          map<long long,long long>
#define mii         map<pii,long long>
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(long long i=a;i<b;i++)
#define repr(i,a,b) for(long long i=a;i>=b;i--)
#define int long long
#define mp make_pair
using namespace std;
//bool v[1000000000];
vi v;

void SieveOfEratosthenes(int n)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    // Print all prime numbers
    for (int p=2; p<=n; p++)
       if (prime[p])
        v.pb(p);
}

signed main()
{
    int n,m;
    cin>>n>>m;
    set<int> s;
    vector<int> ans(n,-1);
    rep(i,0,n)
    {
        s.insert(i);
    }
    rep(i,0,m)
    {
        int l,r,x;
        cin >> l>>r>>x;
        l--,r--,x--;
        set<int>::iterator it = s.lower_bound(l);
        vector<int> er;
        while(it!=s.end())
        {
            int curr = *it;
            if(curr>r)
                break;
            if(curr!=x)
            {
                er.pb(curr);
                ans[curr] = x;
            }
            it++;
        }
        for(int j=0;j<er.size();j++)
            s.erase(er[j]);

    }
    rep(i,0,n) cout << ans[i]+1 << " ";

}


#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define int long long
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define io ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
#define INF 1e7

class Segtree{
    int n;
    vi lo,hi,ans;
    void init(int i,int a,int b)
    {
        lo[i]=a;
        hi[i]=b;
        if(a==b)
            return;
        int mid = (a+b)/2;
        init(2*i,a,mid);
        init(2*i+1,mid+1,b);
    }
    void prop(int i)
    {
        if(lo[i]==hi[i]) return;
        if(ans[i]!=-1)
        {
            increment(2*i,lo[i],hi[i],ans[i]);
            increment(2*i+1,lo[i],hi[i],ans[i]);
        }
        ans[i] = -1;
    }

    void increment(int i,int a,int b,int val)
    {
        if(b<lo[i]||a>hi[i])
            return;
        if(a<=lo[i]&&hi[i]<=b)
        {
            if(ans[i]!=-1) return;
            ans[i] = val;
            return;
        }
        prop(i);
        increment(2*i,a,b,val);
        increment(2*i+1,a,b,val);

    }
    long killedme(int i,int index)
    {
        if(lo[i]==hi[i]) return ans[i];

        prop(i);
        if(index<=hi[2*i]) return killedme(2*i,index);
        else return killedme(2*i+1,index);

    }

public:
    Segtree(int n)
    {
        this->n = n;
        lo.resize(4*n+1);
        hi.resize(4*n+1);
        ans.assign(4*n+1,-1);
       // delta.resize(4*n+1);
        //mini.resize(4*n+1);
        init(1,0,n-1);
    }
    void increment(int a,int b,int val)
    {
        increment(1,a,b,val);
    }
    int killedme(int index)
    {
        return killedme(1,index);

    }

};
signed main()
{
   io;
   int n,m;
   cin >> n >> m;
   Segtree *st = new Segtree(n);
   rep(i,0,m)
   {
    int l,r,x;
    cin >> l >>r >> x;
    l--,r--,x--;
    st->increment(l,x-1,x);
    st->increment(x+1,r,x);
   }
   rep(i,0,n)
   {
    cout << st->killedme(i)+1<< " ";
   }
   cout <<endl;

}


#include <iostream>
#include <climits>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <assert.h>
#include <utility>
#include <string>
#include <bits/stdc++.h>
#include <fstream>
#include <chrono>
using namespace std;

typedef long long LL;

int a[300005];

int n , m , x, y ,z;

set<int>s;
int main (){

 scanf("%d %d",&n , &m );

    for(int i = 0 ; i<m ; i++){

        scanf("%d %d %d",&x , &y , &z );

        for (int j = x-1 ; (j < y) &&  (!a[j]) ; j++){

            if(j+1-z )  a[j]=z;
        }

        for (int j = y-1 ; (j >= x) &&  (!a[j]) ; j--){

            if(j+1-z )  a[j]=z;
        }

        for (auto k = s.begin() ; k!= s.end() ;){

            if (x<=*k && *k<=y && *k !=z ){
                a[*k-1]=z;
               k= s.erase(k);

            }
            else k++;
        }

        s.insert(z);

//puts("\n******");
//for (int i = 0 ; i < n ; i++)printf("%d ",a[i]);
//puts("\n******");

}

for (int i = 0 ; i < n ; i++)printf("%d ",a[i]);

return 0;
}


#include <iostream>
#include <climits>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <assert.h>
#include <utility>
#include <string>
#include <bits/stdc++.h>
#include <fstream>
#include <chrono>
using namespace std;

typedef long long LL;

int a[300005];

int n , m , x, y ,z;

set<int>s;
int main (){

 scanf("%d %d",&n , &m );

    for(int i = 0 ; i<m ; i++){

        scanf("%d %d %d",&x , &y , &z );

        for (int j = x-1 ; (j < y) &&  (!a[j]) ; j++){

            if(j+1-z )  a[j]=z;
        }

        for (int j = y-1 ; (j >= x) &&  (!a[j]) ; j--){

            if(j+1-z )  a[j]=z;
        }

        for (auto k = s.begin() ; k!= s.end() ;){

            if (x<=*k && *k<=y){
                a[*k-1]=z;
               k= s.erase(k);

            }
            else k++;
        }

        s.insert(z);

//puts("\n******");
//for (int i = 0 ; i < n ; i++)printf("%d ",a[i]);
//puts("\n******");

}

for (int i = 0 ; i < n ; i++)printf("%d ",a[i]);

return 0;
}


#include <iostream>
#include <climits>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <assert.h>
#include <utility>
#include <string>
#include <bits/stdc++.h>
#include <fstream>
#include <chrono>
using namespace std;

typedef long long LL;

int a[300005];

int n , m , x, y ,z;
set<int>s;
int main (){

 scanf("%d %d",&n , &m );

 for (int i = 1 ; i <= n ; i++)s.insert(i);

    for(int i = 0 ; i<m ; i++){

        scanf("%d %d %d",&x , &y , &z );

        auto it = s.lower_bound(x);

         while (*it <= y ){

            if (*it==z)it++;
            else{

                a[*it-1]=z;
                s.erase(it++);
            }

            if (it==s.end())break;

         }

    }

 for (int i = 0 ; i < n ; i++)printf("%d ",a[i]);

return 0;
}


#include <iostream>
#include <climits>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <assert.h>
#include <utility>
#include <string>
#include <bits/stdc++.h>
#include <fstream>
#include <chrono>
using namespace std;

typedef long long LL;

int a[300005];

int n , m , x, y ,z;

int main (){

 scanf("%d %d",&n , &m );

    for(int i = 0 ; i<m ; i++){

        scanf("%d %d %d",&x , &y , &z );

        for (int j = x ; j <= y ; j++){

            if( (!a[j-1]) && (j-z) )

                a[j-1]=z;
        }
    }

 for (int i = 0 ; i < n ; i++)printf("%d ",a[i]);

return 0;
}


#include <iostream>
#include <climits>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <assert.h>
#include <utility>
#include <string>
#include <bits/stdc++.h>
#include <fstream>
#include <chrono>
using namespace std;

typedef long long LL;

int a[300005];

int n , m , x, y ,z;

int main (){

 scanf("%d %d",&n , &m );

    for(int i = 0 ; i<m ; i++){

        scanf("%d %d %d",&x , &y , &z );

            x-- ;
           int idx = find(a+x , a+y , 0)-a;
           while (idx < y && (idx!=-1)){

             if(  idx+1-z ) a[idx]=z;

            idx = find(a+idx+1 , a+y , 0)-a;
            }

    }

 for (int i = 0 ; i < n ; i++)printf("%d ",a[i]);

return 0;
}


#include <iostream>
#include <climits>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <assert.h>
#include <utility>
#include <string>
#include <bits/stdc++.h>
#include <fstream>
#include <chrono>
using namespace std;

typedef long long LL;

int a[300005];

int n , m , x, y ,z;

set<int>s;
int main (){

 scanf("%d %d",&n , &m );

    for(int i = 0 ; i<m ; i++){

        scanf("%d %d %d",&x , &y , &z );

        for (int j = x-1 ; (j < y) &&  (!a[j]) ; j++){

            if(j+1-z )  a[j]=z;
        }

        for (int j = y-1 ; (j >= x) &&  (!a[j]) ; j--){

            if(j+1-z )  a[j]=z;
        }

        for (auto k = s.begin() ; k!= s.end() ;){

            if (x<=*k && *k<=y && *k !=z ){
                a[*k-1]=z;
               k= s.erase(k);

            }
            else k++;
        }

        s.insert(z);

//puts("\n******");
//for (int i = 0 ; i < n ; i++)printf("%d ",a[i]);
//puts("\n******");

}

for (int i = 0 ; i < n ; i++){
    if (!a[i] && (i+1!= z))printf("%d ",z);
    else  printf("%d ",a[i]);
   }

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f(i,n) for(int i=0;i<(n);i++)
#define rep(i,a,n) for(int i=(a);i<=(n);i++)
#define vi vector<int>
#define pi pair<int,int>
#define pb push_back
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define ll long long int
const int mod = 1e9+7;

int main() {
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

    int n,m;
    cin>>n>>m;
    set<int> s;
    rep(i,1,n)
    s.insert(i);
    int ans[n+1]={0};
    while(m--){
      int l,r,x;
      cin>>l>>r>>x;
      vi del;
      auto it = s.lower_bound(l);
      while(it!=s.end()){
        if(*it != x){
          ans[*it]=x;
          del.pb(*it);
        }
        if(*it >= r)
          break;
        it++;
      }
      for(auto i : del)
        s.erase(i);
    }
    rep(i,1,n)
    cout<<ans[i]<<" ";
    cout<<"\n";

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f(i,n) for(int i=0;i<(n);i++)
#define rep(i,a,n) for(int i=(a);i<=(n);i++)
#define vi vector<int>
#define pi pair<int,int>
#define pb push_back
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define ll long long int
const int mod = 1e9+7;

int main() {
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

    int n,m;
    cin>>n>>m;
    set<int> s;
    rep(i,1,n)
    s.insert(i);
    int ans[n+1]={0};
    while(m--){
      int l,r,x;
      cin>>l>>r>>x;
      vi del;
      auto it = s.lower_bound(l);
      while(it!=s.end()){
        if(*it > r)
          break;
        if(*it != x){
          ans[*it]=x;
          del.pb(*it);
        }

        it++;
      }
      for(auto i : del)
        s.erase(i);
    }
    rep(i,1,n)
    cout<<ans[i]<<" ";
    cout<<"\n";

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f(i,n) for(int i=0;i<(n);i++)
#define rep(i,a,n) for(int i=(a);i<=(n);i++)
#define vi vector<int>
#define pi pair<int,int>
#define pb push_back
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define ll long long int
const int mod = 1e9+7;

int main() {
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

    int n,m;
    cin>>n>>m;
    set<int> s;
    rep(i,1,n)
    s.insert(i);
    int ans[n+1]={0};
    while(m--){
      int l,r,x;
      cin>>l>>r>>x;
      vi del;
      auto it = s.lower_bound(l);
      while(1){
        if(*it != x){
          ans[*it]=x;
          del.pb(*it);
        }
        if(*it >= r)
          break;
        it++;
      }
      for(auto i : del)
        s.erase(i);
    }
    rep(i,1,n)
    cout<<ans[i]<<" ";
    cout<<"\n";

  return 0;
}


#include <bits/stdc++.h>
#define here cout << "here\n";
#define ex exit(0)
#define ndl "\n"
#define pb push_back
#define pp pop_back
#define sc scanf
#define pnt printf
#define y1 NOTHING_STOP_ME
#define repu(i, x, n) for(i = x ; i <= n ; i++)
#define repd(i, n, x) for(i = n ; i >= x ; --i)
#define IOI ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define SZ(x) x.size()
#define NDL cout << ndl;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ldubl;

const int inf1 = (int) 1e9 + 1;
const ll INF1 = (ll) 1e18 + 1;

const int inf = (int) 2147483647;
const ll INF = (ll) 9223372036854775807ll;

const int N6 = (int) 1e6 + 1;
const int N5 = (int) 1e5 + 1;
const int N4 = (int) 1e4 + 1;
const int N3 = (int) 1e3 + 1;
const int N2 = (int) 1e2 + 1;
const int N = (int) 1e4;

const int mod = (int) 1e9 + 7;

int n, m, k;
int i, j;

int l, r, x;

set <int> alive;
set <int> :: iterator it;
int cur;
vector <int> to_kill;
int ans[N5 * 3];

int main () {
	cin >> n >> m;
	repu(i, 1, n)
		alive.insert(i);
	repu(i, 1, m) {
		sc("%d %d %d", &l, &r, &x);
		it = alive.lower_bound(l);
		while(it != alive.end()) {
			cur = *it;
			if(cur > r)
				break;
			if(cur != x)
				to_kill.pb(cur), ans[cur] = x;
			it++;
		}
		for(j = 0 ; j < to_kill.size() ; j++)
			alive.erase(to_kill[j]);
		to_kill.clear();
	}

	repu(i, 1, n)
		cout << ans[i] << " ";
	return 0;
}


#include <bits/stdc++.h>
#define here cout << "here\n";
#define ex exit(0)
#define ndl "\n"
#define pb push_back
#define pp pop_back
#define sc scanf
#define pnt printf
#define y1 NOTHING_STOP_ME
#define repu(i, x, n) for(i = x ; i <= n ; i++)
#define repd(i, n, x) for(i = n ; i >= x ; --i)
#define IOI ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define SZ(x) x.size()
#define NDL cout << ndl;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ldubl;

const int inf1 = (int) 1e9 + 1;
const ll INF1 = (ll) 1e18 + 1;

const int inf = (int) 2147483647;
const ll INF = (ll) 9223372036854775807ll;

const int N6 = (int) 1e6 + 1;
const int N5 = (int) 1e5 + 1;
const int N4 = (int) 1e4 + 1;
const int N3 = (int) 1e3 + 1;
const int N2 = (int) 1e2 + 1;
const int N = (int) 1e4;

const int mod = (int) 1e9 + 7;

int n, m, k;
int i, j, it;

struct Pair {
    int l, r, x;
}a[N5 * 3];

bool alive[N5 * 3];
int from[N5 * 3];

int main () {
    IOI
    cin >> n >> m;
    repu(i, 1, m)
        cin >> a[i].l >> a[i].r >> a[i].x;
    repu(i, 1, n)
        alive[i] = true;
    repu(i, 1, m) {
        repu(j, a[i].l, a[i].x - 1)
            if(alive[j])
                alive[j] = false, from[j] = a[i].x;
        repu(j, a[i].x + 1, a[i].r) {
            if(alive[j])
                alive[j] = false, from[j] = a[i].x;
        }
    }

    for(i = 1 ; i <= n ; i++)
        cout << from[i] << " ";
    return 0;
}


#include <bits/stdc++.h>
#define here cout << "here\n";
#define ex exit(0)
#define ndl "\n"
#define pb push_back
#define pp pop_back
#define sc scanf
#define pnt printf
#define y1 NOTHING_STOP_ME
#define repu(i, x, n) for(i = x ; i <= n ; i++)
#define repd(i, n, x) for(i = n ; i >= x ; --i)
#define IOI ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define SZ(x) x.size()
#define NDL cout << ndl;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ldubl;

const int inf1 = (int) 1e9 + 1;
const ll INF1 = (ll) 1e18 + 1;

const int inf = (int) 2147483647;
const ll INF = (ll) 9223372036854775807ll;

const int N6 = (int) 1e6 + 1;
const int N5 = (int) 1e5 + 1;
const int N4 = (int) 1e4 + 1;
const int N3 = (int) 1e3 + 1;
const int N2 = (int) 1e2 + 1;
const int N = (int) 1e4;

const int mod = (int) 1e9 + 7;

int n, m, k;
int i, j;

int l, r, x;

set <int> alive;
set <int> :: iterator it;
int cur;
vector <int> to_kill;
int ans[N5 * 3];

int main () {
	IOI
	cin >> n >> m;
	repu(i, 1, n)
		alive.insert(i);
	repu(i, 1, m) {
		sc("%d %d %d", &l, &r, &x);
		it = alive.lower_bound(l);
		while(it != alive.end()) {
			cur = *it;
			if(cur > r)
				break;
			if(cur != x)
				to_kill.pb(cur), ans[cur] = x;
			it++;
		}
		for(j = 0 ; j < to_kill.size() ; j++)
			alive.erase(to_kill[j]);
	}

	repu(i, 1, n)
		cout << ans[i] << " ";
	return 0;
}


#include <bits/stdc++.h>
#define here cout << "here\n";
#define ex exit(0)
#define ndl "\n"
#define pb push_back
#define pp pop_back
#define sc scanf
#define pnt printf
#define y1 NOTHING_STOP_ME
#define repu(i, x, n) for(i = x ; i <= n ; i++)
#define repd(i, n, x) for(i = n ; i >= x ; --i)
#define IOI ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define SZ(x) x.size()
#define NDL cout << ndl;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ldubl;

const int inf1 = (int) 1e9 + 1; // repeat

const ll INF1 = (ll) 1e18 + 1;

const int inf = (int) 2147483647;
const ll INF = (ll) 9223372036854775807ll;

const int N6 = (int) 1e6 + 1;
const int N5 = (int) 1e5 + 1;
const int N4 = (int) 1e4 + 1;
const int N3 = (int) 1e3 + 1;
const int N2 = (int) 1e2 + 1;
const int N = (int) 1e4;

const int mod = (int) 1e9 + 7;

int n, m, k;
int i, j;

int l, r, x;

set <int> alive;
set <int> :: iterator it;
int cur;
vector <int> to_kill;
int ans[N5 * 3];

int main () {
	IOI
	cin >> n >> m;
	repu(i, 1, n)
		alive.insert(i);
	repu(i, 1, m) {
		sc("%d %d %d", &l, &r, &x);
		it = alive.lower_bound(l);
		while(it != alive.end()) {
			cur = *it;
			if(cur > r)
				break;
			if(cur != x)
				to_kill.pb(cur), ans[cur] = x;
			it++;
		}
		for(j = 0 ; j < to_kill.size() ; j++)
			alive.erase(to_kill[j]);
	}

	repu(i, 1, n)
		cout << ans[i] << " ";
	return 0;
}


#include <bits/stdc++.h>
#define here cout << "here\n";
#define ex exit(0)
#define ndl "\n"
#define pb push_back
#define pp pop_back
#define sc scanf
#define pnt printf
#define y1 NOTHING_STOP_ME
#define repu(i, x, n) for(i = x ; i <= n ; i++)
#define repd(i, n, x) for(i = n ; i >= x ; --i)
#define IOI ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define SZ(x) x.size()
#define NDL cout << ndl;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ldubl;

const int inf1 = (int) 1e9 + 1;
const ll INF1 = (ll) 1e18 + 1;

const int inf = (int) 2147483647;
const ll INF = (ll) 9223372036854775807ll;

const int N6 = (int) 1e6 + 1;
const int N5 = (int) 1e5 + 1;
const int N4 = (int) 1e4 + 1;
const int N3 = (int) 1e3 + 1;
const int N2 = (int) 1e2 + 1;
const int N = (int) 1e4;

const int mod = (int) 1e9 + 7;

int n, m, k;
int i, j;

int l, r, x;

set <int> alive;
set <int> :: iterator it;
int cur;
vector <int> to_kill;
int ans[N5 * 3];

int main () {
	IOI
	cin >> n >> m;
	repu(i, 1, n)
		alive.insert(i);
	repu(i, 1, m) {
		sc("%d %d %d", &l, &r, &x);
		it = alive.lower_bound(l);
		while(it != alive.end()) {
			cur = *it;
			if(cur > r)
				break;
			if(cur != x)
				to_kill.pb(cur), ans[cur] = x;
			it++;
		}
		for(j = 0 ; j < to_kill.size() ; j++)
			alive.erase(to_kill[j]);
		to_kill.clear();
	}

	repu(i, 1, n)
		cout << ans[i] << " ";
	return 0;
}


#include<iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int n , m;
    cin >> n >> m;

   set<int>s;
   set<int>::iterator it,z;

   for(int i = 1 ; i<=n ;i++)
        s.insert(i);

    vector<int>res(n+1);

   for(int i=0 ; i<m ;i++){
       int l , r , x;
       cin >> l >> r >> x;

       it = s.lower_bound(l);
       while(*it <=r ){
           if(it==s.end())
                break;

            else if(*it!=x)
                res[*it]=x , s.erase(it++);

            else
                it++;
        }
   }

   for(int i = 1 ;i<=n ;i++)
        cout << res[i]<< " ";

}


#include<iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int n , m;
    cin >> n >> m;

   int a[n+1];

   for(int i=1 ;i<=n ; i++)
        a[i] = -1;

    for(int i = 1 ;i<=m  ;i++){
        int l , r , x;
        cin >> l >> r >> x;

        for(int j = l ; j<=r  ;j++){
            if(a[j]== -1 && j!=x)
                a[j]=x;
            }

    }
    for(int i=1 ;i<=n ;i++){
        if(a[i]== -1)
            a[i]=0;
        cout << a[i] <<" ";
    }
}


#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m, l, r, x; cin>>n>>m;
    int winwin[n+1] = {0};
    while(m--){
        cin>>l>>r>>x;
        for(int i = l; i<=r; i++){
            if(i==x) continue;
            if(!winwin[i]) winwin[i] = x;
        }
    }
    for(int i = 1; i<=n; i++) cout<<winwin[i]<<" ";
    cout<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m, l, r, x; cin>>n>>m;
    set<int> s;
    for(int i = 1; i<=n; i++) s.insert(i);
    int winwin[n+1] = {0};
    while(m--){
        cin>>l>>r>>x;
        auto lt = s.lower_bound(l), rt = s.upper_bound(r);
        for(auto it = lt; it!=rt; it++){
            int v = *it;
            if(v!=x) winwin[v] = x;
        }
        s.erase(lt, rt);
        s.insert(x);
    }
    for(int i = 1; i<=n; i++) cout<<winwin[i]<<" ";
    cout<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define speed ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
unordered_map<ll,ll>knight;
int main(){
    speed;
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<m;i++){
        ll l,r,x;
        cin>>l>>r>>x;
        knight[x]=0;
        for(ll j=l;j<=r;j++)
            if(knight[j]==0 && j!=x)
                knight[j]=x;
    }
    for(ll i=1;i<=n;i++)
        cout<<knight[i]<<' ';
}


#include<bits/stdc++.h>
#define ll long long
#define speed ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
set<ll>alive;
unordered_map<ll,ll>answer;
int main(){
    speed;
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<=n;i++)
        alive.insert(i);
    for(ll i=0;i<m;i++){
        ll l,r,x;
        cin>>l>>r>>x;
        set<ll>::iterator it=alive.lower_bound(l);
        vector<ll>erasing;
        while(it!=alive.end()){
            if(*it>r)
                break;
            if(*it!=x)
                erasing.push_back(*it),answer[*it]=x;
            it++;
        }
        for(ll j=0;j<erasing.size();j++)
            alive.erase(erasing[j]);
        }
        for(ll i=1;i<=n;i++)
            cout<<answer[i]<<' ';
}


/* Segment tree */

#include <iostream>
#include <vector>
#include <utility>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <fstream>

using namespace std;

#define mp make_pair
#define pb push_back

int a[300001];
int s[1500000];

void build(int id, int l, int r, int num1, int num2, int num3){
	if (r <= num1)
		return;

	if (l > num2)
		return;
	if (r - l < 2){
        if (l != num3-1){
            s[id] = num3;
            a[l] = num3;
        }
		return ;
	}

	int midpoint = (l + r) / 2;
	if (s[id*2] == 0){
		build(id*2, l, midpoint, num1, num2, num3);
	}
	if (s[id*2+1] == 0){
		build(id*2+1, midpoint, r, num1, num2, num3);
	}
	if ((s[id*2] != 0) && (s[id*2+1] != 0)){
		s[id] = 1;
	}
}

int main() {

    std::ios::sync_with_stdio(false);
    memset(s, 0, sizeof s);
    memset(a, 0, sizeof a);

    int n, m, num1, num2, num3;

    cin>>n>>m;

    for (int i=0; i<m; i++){
    	cin>>num1>>num2>>num3;
    	num1--;
    	num2--;
    	build(1, 0, n, num1, num2, num3);
    }

    for (int i=0; i<n; i++){
    	cout<<a[i]<<" ";
    }

    return 0;
}


/* Segment tree */

#include <iostream>
#include <vector>
#include <utility>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <fstream>

using namespace std;

#define mp make_pair
#define pb push_back

int a[300001];
int s[700000];

void build(int id, int l, int r, int num1, int num2, int num3){
	if (r <= num1)
		return;

	if (l > num2)
		return;
	if (r - l < 2){
        if (l != num3-1){
            s[id] = num3;
            a[l] = num3;
        }
		return ;
	}

	int midpoint = (l + r) / 2;
	if (s[id*2] == 0){
		build(id*2, l, midpoint, num1, num2, num3);
	}
	if (s[id*2+1] == 0){
		build(id*2+1, midpoint, r, num1, num2, num3);
	}
	if ((s[id*2] != 0) && (s[id*2+1] != 0)){
		s[id] = 1;
	}
}

int main() {

    std::ios::sync_with_stdio(false);
    memset(s, 0, sizeof s);
    memset(a, 0, sizeof a);

    int n, m, num1, num2, num3;

    cin>>n>>m;

    for (int i=0; i<m; i++){
    	cin>>num1>>num2>>num3;
    	num1--;
    	num2--;
    	build(1, 0, n, num1, num2, num3);
    }

    for (int i=0; i<n; i++){
    	cout<<a[i]<<" ";
    }

    return 0;
}


/* Segment tree */

#include <iostream>
#include <vector>
#include <utility>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <fstream>

using namespace std;

#define mp make_pair
#define pb push_back

int a[300001];
int s[525000];

void build(int id, int l, int r, int num1, int num2, int num3){
	if (r <= num1)
		return;

	if (l > num2)
		return;
	if (r - l < 2){
        if (l != num3-1){
            s[id] = num3;
            a[l] = num3;
        }
		return ;
	}

	int midpoint = (l + r) / 2;
	if (s[id*2] == 0){
		build(id*2, l, midpoint, num1, num2, num3);
	}
	if (s[id*2+1] == 0){
		build(id*2+1, midpoint, r, num1, num2, num3);
	}
	if ((s[id*2] != 0) && (s[id*2+1] != 0)){
		s[id] = 1;
	}
}

int main() {

    std::ios::sync_with_stdio(false);
    memset(s, 0, sizeof s);
    memset(a, 0, sizeof a);

    int n, m, num1, num2, num3;

    cin>>n>>m;

    for (int i=0; i<m; i++){
    	cin>>num1>>num2>>num3;
    	num1--;
    	num2--;
    	build(1, 0, n, num1, num2, num3);
    }

    for (int i=0; i<n; i++){
    	cout<<a[i]<<" ";
    }

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
struct pointS {
    int i;
    int x;
};

vector<pointS> start[400000];
vector<pointS> endd[400000];
int isIn[400000] = {0};
bool cmp(const pointS& a,const pointS& b) {
    return a.i>b.i;
}
vector<pointS> heap;
int main() {
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i = 0;i < m;i++) {
        int l,r,x;
        scanf("%d %d %d",&l,&r,&x);
        pointS p = {i,x};
        if(l < x) {
            start[l].push_back(p);
            endd[x].push_back(p);
        }
        if(x < r) {
            start[x+1].push_back(p);
            endd[r+1].push_back(p);
        }
    }
    for(int i = 1;i <= n;i++) {
        // remove end event
        for(int j = 0;j < endd[i].size();j++) {
            isIn[endd[i][j].x]--;
        }
        // add start event
        for(int j = 0;j < start[i].size();j++) {
            isIn[start[i][j].x]++;
            heap.push_back(start[i][j]);
            push_heap(heap.begin(),heap.end(),cmp);
        }
        /*printf("\n[");
        for(int x = Qs;x < Qe;x++) printf("%d ",Q[x]);
        printf("]\n");*/
        // iterate through evQ
        int ans = 0;
        while(true) {
            if(heap.size() == 0) {
                // no fight here ?
                break;
            }
            if(isIn[heap[0].x]==0) {
                // removed already
                pop_heap(heap.begin(),heap.end(),cmp);
                heap.pop_back();
            }
            else {
                ans = heap[0].x;
                break;
            }
        }
        printf("%d ",ans);
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
struct eventS {
    int i;
    bool start;
};
struct pointS {
    int i;
    int x;
};
using namespace std;
vector<pointS> start[400000];
vector<pointS> endd[400000];
bool isIn[400000];
bool cmp(const pointS& a,const pointS& b) {
    return a.i>b.i;
}
vector<pointS> heap;
int main() {
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i = 0;i < m;i++) {
        int l,r,x;
        scanf("%d %d %d",&l,&r,&x);
        pointS p = {i,x};
        if(l < x) {
            start[l].push_back(p);
            endd[x].push_back(p);
        }
        if(x < r) {
            start[x+1].push_back(p);
            endd[r+1].push_back(p);
        }
    }
    for(int i = 1;i <= n;i++) {
        // remove end event
        for(int j = 0;j < endd[i].size();j++) {
            isIn[endd[i][j].x] = false;
        }
        // add start event
        for(int j = 0;j < start[i].size();j++) {
            isIn[start[i][j].x] = true;
            heap.push_back(start[i][j]);
            push_heap(heap.begin(),heap.end(),cmp);
        }
        /*printf("\n[");
        for(int x = Qs;x < Qe;x++) printf("%d ",Q[x]);
        printf("]\n");*/
        // iterate through evQ
        int ans = 0;
        while(true) {
            if(heap.size() == 0) {
                // no fight here ?
                break;
            }
            if(!isIn[heap[0].x]) {
                // removed already
                pop_heap(heap.begin(),heap.end(),cmp);
                heap.pop_back();
            }
            else {
                ans = heap[0].x;
                break;
            }
        }
        printf("%d ",ans);
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
struct eventS {
    int i;
    bool start;
};
struct pointS {
    int i;
    int x;
};
using namespace std;
vector<pointS> start[400000];
vector<pointS> endd[400000];
bool isIn[400000];
bool cmp(const pointS& a,const pointS& b) {
    return a.i>b.i;
}
vector<pointS> heap;
int main() {
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i = 0;i < m;i++) {
        int l,r,x;
        scanf("%d %d %d",&l,&r,&x);
        pointS p = {i,x};
        if(l < x) {
            start[l].push_back(p);
            endd[x].push_back(p);
        }
        if(x < r) {
            start[x+1].push_back(p);
            endd[r+1].push_back(p);
        }
    }
    for(int i = 1;i <= n;i++) {
        // remove end event
        for(int j = 0;j < endd[i].size();j++) {
            isIn[endd[i][j].x] = false;
        }
        // add start event
        for(int j = 0;j < start[i].size();j++) {
            isIn[start[i][j].x] = true;
            heap.push_back(start[i][j]);
            push_heap(heap.begin(),heap.end(),cmp);
        }
        /*printf("\n[");
        for(int x = Qs;x < Qe;x++) printf("%d ",Q[x]);
        printf("]\n");*/
        // iterate through evQ
        int ans = 0;
        while(true) {
            if(heap.size() == 0) {
                // no fight here ?
                break;
            }
            if(!isIn[heap[0].x]) {
                // removed already
                pop_heap(heap.begin(),heap.end(),cmp);
                heap.pop_back();
            }
            else {
                ans = heap[0].x;
                break;
            }
        }
        printf("%d ",ans);
    }
}


#include <bits/stdc++.h>

using namespace std;

int v[1005];
vector<int> ans;

bool valid(int tam, int n){
    for(int i = 0; (i+tam) < n; i++)    // i = 0 because A0 = 0
        if(v[i+1] - v[i] != v[i+tam+1] - v[i+tam]) return false;
    return true;
}

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    for(int i = 1; i <= n; i++)
        if(valid(i,n)) ans.push_back(i);
    cout << ans.size() << endl;
    for(auto i:ans)cout << i <<" ";
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int v[1004];
vector<int> ans;

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> v[i];
    if(n == 1){
        cout << 1 << endl << 1 << endl;
        return 0;
    }
    if((v[1] - v[0] == 1))ans.push_back(1);
    for(int i = 2; i < n; i++){
        int xx = v[i] - v[i-1];
        //cout << v[i]  <<" " << xx << endl;
        if(xx == 1)ans.push_back(i);
    }
    ans.push_back(n);
    cout << ans.size() << endl;
    for(auto i:ans)cout <<i <<" ";
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int v[1004];
vector<int> ans;

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> v[i];
    if(n == 1 || (v[1] - v[0] == 1))ans.push_back(1);
    for(int i = 2; i < n; i++){
        int xx = v[i] - v[i-1];
        //cout << v[i]  <<" " << xx << endl;
        if(xx == 1)ans.push_back(i);
    }
    ans.push_back(n);
    cout << ans.size() << endl;
    for(auto i:ans)cout <<i <<" ";
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef pair<int, int> pii;

const int MAXN = (int) 1e3;

int n;

int a[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i <= n; ++i) a[i] = read<int>();
}

inline void build_fail(int *s, int *fail)
{
	fail[1] = 0;
	for(int i = 2, j = 0; i <= n; ++i)
	{
		while(j && s[i] != s[j + 1]) j = fail[j];
		if(s[i] == s[j + 1]) fail[i] = ++j;
		fail[i] = j;
	}
}

inline void solve()
{
	static int s[MAXN + 5], fail[MAXN + 5];

	for(int i = 1; i <= n; ++i) s[i] = a[i] - a[i - 1];
	build_fail(s, fail);

	static vector<int> ans;

	for(int i = fail[n]; i; i = fail[i]) ans.push_back(n - i);
	ans.push_back(n);

	sort(ALL(ans)), ans.erase(unique(ALL(ans)), ans.end());

	printf("%d\n", SZ(ans));
	for(auto it : ans) printf("%d ", it);
	puts("");
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("B.in", "r", stdin);
	freopen("B.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef pair<int, int> pii;

const int MAXN = (int) 1e3;

int n;

int a[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i <= n; ++i) a[i] = read<int>();
}

inline void build_fail(int *s, int *fail)
{
	fail[1] = 0;
	for(int i = 2, j = 0; i <= n; ++i)
	{
		while(j && s[i] != s[j + 1]) j = fail[j];
		if(s[i] == s[j + 1]) fail[i] = ++j;
		else j = 1;
	}
}

inline void solve()
{
	static int s[MAXN + 5], fail[MAXN + 5];

	for(int i = 1; i <= n; ++i) s[i] = a[i] - a[i - 1];
	build_fail(s, fail);

	static vector<int> ans;

	for(int i = fail[n]; i; i = fail[i]) ans.push_back(n - i);
	ans.push_back(n);

	sort(ALL(ans)), ans.erase(unique(ALL(ans)), ans.end());

	printf("%d\n", SZ(ans));
	for(auto it : ans) printf("%d ", it);
	puts("");
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("B.in", "r", stdin);
	freopen("B.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef pair<int, int> pii;

const int MAXN = (int) 1e3;

int n;

int a[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i <= n; ++i) a[i] = read<int>();
}

inline void build_fail(int *s, int *fail)
{
	fail[1] = 0;
	for(int i = 2, j = 0; i <= n; ++i)
	{
		while(j && s[i] != s[j + 1]) j = fail[j];
		if(s[i] == s[j + 1]) fail[i] = ++j;
		else j = 1;
	}
}

inline void solve()
{
	static int s[MAXN + 5], fail[MAXN + 5];

	for(int i = 1; i <= n; ++i) s[i] = a[i] - a[i - 1];
	build_fail(s, fail);

	static vector<int> ans;

	for(int i = fail[n]; i; i = fail[i]) ans.push_back(n - i);
	ans.push_back(n);

	printf("%d\n", SZ(ans));
	for(auto it : ans) printf("%d ", it);
	puts("");
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("B.in", "r", stdin);
	freopen("B.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
#define ll long long int

int main()
{

ll n;
cin>>n;
vector<ll> ans;

vector<ll> v(n);

for(ll i=0;i<n;i++)
{
	cin>>v[i];

}
for(ll i=0;i<n;i++)
{
	if(i==0)
	ans.push_back(v[i]);
	else
	ans.push_back(v[i]-v[i-1]);
}
ll counter=0;
vector<ll> ans1;
for(ll i=1;i<=n;i++)
{
	ll j;
	for(j=0;j<n;j++)
	{
		if(ans[j]!=ans[j+i] && (j+i)<n)
		break;
	}
	if(j>=n)
	{
		counter++;
		ans1.push_back(i);
	}
}

cout<<counter<<endl;
for(ll j=0;j<counter;j++)
cout<<ans1[j]<<" ";
return 0;

}


#include<iostream>
#include<vector>
using namespace std;
#define ll long long int

int main()
{

ll n;
cin>>n;
vector<ll> ans;

vector<ll> v(n);

for(ll i=0;i<n;i++)
{
	cin>>v[i];

}
for(ll i=0;i<n;i++)
{
	if(i==0)
	ans.push_back(v[i]);
	else
	ans.push_back(v[i]-v[i-1]);
}
ll counter=1;
vector<ll> ans1;
for(ll i=1;i<n;i++)
{
	ll j;
	for(j=0;j<n;j++)
	{
		if(ans[j]!=ans[j+i] && (j+i)<n)
		break;
	}
	if(j>=n)
	{
		counter++;
		ans1.push_back(i);
	}
}
ans1.push_back(n);

cout<<counter<<endl;
for(ll j=0;j<counter;j++)
cout<<ans1[j]<<" ";

return 0;

}


#include<iostream>
#include<vector>
using namespace std;
#define ll long long int

int main()
{

ll n;
cin>>n;
vector<ll> ans;

vector<ll> v(n);

for(ll i=0;i<n;i++)
{
	cin>>v[i];

}
for(ll i=0;i<n;i++)
{
	if(i==0)
	ans.push_back(v[i]);
	else
	ans.push_back(v[i]-v[i-1]);
}
ll counter=0;
vector<ll> ans1;
for(ll i=1;i<=n;i++)
{
	ll j;
	for(j=0;j<n;j++)
	{
		if(ans[j]!=ans[j+i] && (j+i)<n)
		break;
	}
	if(j>=n)
	{
		counter++;
		ans1.push_back(i);
	}
}

cout<<counter<<endl;
for(ll j=0;j<counter;j++)
cout<<ans1[j]<<" ";

return 0;

}


#include<iostream>
#include<vector>
using namespace std;
#define ll long long int

int main()
{

ll n;
cin>>n;
vector<ll> ans;

vector<ll> v(n);
cout<<n<<endl;
for(ll i=0;i<n;i++)
{
	cin>>v[i];
	if(i==0)
	cout<<(v[i])<<" ";
	else
	cout<<(v[i]-v[i-1])<<" ";
}

return 0;
}


#include<iostream>
#include<vector>
using namespace std;
#define ll long long int

int main()
{

ll n;
cin>>n;
vector<ll> ans;

vector<ll> v(n);

for(ll i=0;i<n;i++)
{
	cin>>v[i];

}
for(ll i=0;i<n;i++)
{
	if(i==0)
	ans.push_back(v[i]);
	else
	ans.push_back(v[i]-v[i-1]);
}
ll counter=1;
vector<ll> ans1;
for(ll i=1;i<n;i++)
{
	ll j;
	for(j=0;j<n;j++)
	{
		if((j+i)<n && ans[j]!=ans[j+i] )
		break;
	}
	if(j>=n)
	{
		counter++;
		ans1.push_back(i);
	}
}
ans1.push_back(n);

cout<<counter<<endl;
for(ll j=0;j<counter;j++)
cout<<ans1[j]<<" ";

return 0;

}


#include <bits/stdc++.h>
#include <numeric>
#include <iterator>
#include <stdio.h>
#define ll long long
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define sz(a) int((a).size())
#define all(a) (a).begin(),(a).end()
#define fr(i,p,n) for(int i=p;i<n;i++)
#define precise cout << std::setprecision(10) << std::fixed;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
//ll M=1000000007;
//double pi=3.1415926535898;
//ll M=  998244353;
typedef pair<int, int> pairs;
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int main()
{
    fastio; //precise;

    int T=1;
    //cin>>T;
    while(T--){
        int n,ans=0;
        cin>>n;
        int a[n+1];
        a[0]=0;
        int b[n];
        fr(i,0,n) {
         cin>>a[i+1];
         b[i]=a[i+1]-a[i]; }
         //fr(i,0,n) cout<<a[i]<<" ";
         //cout<<endl;
        vector<int> v;
        fr(i,1,n+1){
        int j=0;
        while(j<n){
           if(b[j]!= b[j%i] ) break;
           j++;
        }
        if(j==n) { v.pb(i); }
        }
        ans=sz(v);
        cout<<ans<<endl;
        fr(i,0,ans) cout<<v[i]<<" ";

    }
     return 0;
}
//cout<<"YES"<<endl;
//cout<<"NO"<<endl;


#include <bits/stdc++.h>
#include <numeric>
#include <iterator>
#include <stdio.h>
#define ll long long
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define sz(a) int((a).size())
#define all(a) (a).begin(),(a).end()
#define fr(i,p,n) for(int i=p;i<n;i++)
#define precise cout << std::setprecision(10) << std::fixed;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
//ll M=1000000007;
//double pi=3.1415926535898;
//ll M=  998244353;
typedef pair<int, int> pairs;
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int main()
{
    fastio; //precise;

    int T=1;
    //cin>>T;
    while(T--){
        int n,k,ans=0;
        cin>>n;
        int a[n+1];
        a[0]=0;
        int b[n];
        fr(i,0,n) {
         cin>>a[i+1];
         b[i]=a[i+1]-a[i]; }
        fr(i,1,n+1){
        int j=0;
        while(j<n){
           if(b[j]!= b[j%i] ) break;
           j++;
        }
        if(j==n) { k=i; break; }
        }
        ans=ceil(n/(k*1.0));

        cout<<ans<<endl;
        fr(i,0,ans) cout<<min((i+1)*k,n)<<" ";
    }
     return 0;
}
//cout<<"YES"<<endl;
//cout<<"NO"<<endl;


#include <bits/stdc++.h>
#include <numeric>
#include <iterator>
#include <stdio.h>
#define ll long long
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define sz(a) int((a).size())
#define all(a) (a).begin(),(a).end()
#define fr(i,p,n) for(int i=p;i<n;i++)
#define precise cout << std::setprecision(10) << std::fixed;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
//ll M=1000000007;
//double pi=3.1415926535898;
//ll M=  998244353;
typedef pair<int, int> pairs;
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int main()
{
    fastio; //precise;

    int T=1;
    //cin>>T;
    while(T--){
        int n,ans=0;
        cin>>n;
        int a[n+1];
        a[0]=0;
        int b[n];
        fr(i,0,n) {
         cin>>a[i+1];
         b[i]=a[i+1]-a[i]; }
         //fr(i,0,n) cout<<a[i]<<" ";
         //cout<<endl;
        int k=n;
        fr(i,1,n+1){
        int j=0;
        while(j<n){
           if(b[j]!= b[j%i] ) break;
           j++;
        }
        if(j==n) { k=i; break; }
        }
        ans=n/k + (n%k>0);
        cout<<ans<<endl;
        fr(i,0,ans) cout<<min((i+1)*k,n)<<" ";
    }
     return 0;
}
//cout<<"YES"<<endl;
//cout<<"NO"<<endl;


#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int a[maxn];

int main() {
    int n=read();
    for(int i=1; i<=n; ++i) a[i]=read();
    for(int i=n; i>1; --i) {
        a[i]=a[i]-a[i-1];
    }
    int d=0; int ans=0;
    for(int i=1; i<=n; ++i) {
        int f=1;
        for(int j=i+1; j<=n; ++j) {
            if(a[j]!=a[j-i]) { f=0; break; }
        }
        if(f) { ans++; }
    }
    cout<<endl;
}


#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int a[maxn];

int main() {
    int n=read();
    for(int i=1; i<=n; ++i) a[i]=read();
    for(int i=n; i>1; --i) {
        a[i]=a[i]-a[i-1];
    }
    int d=0;
    for(int i=1; i<=n; ++i) {
        int f=1;
        for(int j=i+1; j<=n; ++j) {
            if(a[j]!=a[(j-1)%i+1]) { f=0; break; }
        }
        if(f) { d=i; break; }
    }
    cout<<(n-1)/d+1<<endl;
    for(int i=1; i<=(n-1)/d+1; ++i) printf("%d ", min(d*i,n));
    cout<<endl;
}


#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int a[maxn];

int main() {
    int n=read();
    for(int i=1; i<=n; ++i) a[i]=read();
    for(int i=n; i; --i) {
        a[i]=a[i]-a[i-1];
    }
    int d=0;
    for(int i=1; i<=n; ++i) {
        int f=1;
        for(int j=i+1; j<=n; ++j) {
            if(a[j]!=a[(j-1)%i+1]) { f=0; break; }
        }
        if(f) { d=i; break; }
    }
    cout<<(n-1)/d+1<<endl;
    for(int i=1; i<=(n-1)/d+1; ++i) printf("%d ", min(d*i,n));
    cout<<endl;
}


#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int a[maxn];

int main() {
    int n=read();
    for(int i=1; i<=n; ++i) a[i]=read();
    for(int i=n; i>1; --i) {
        a[i]=a[i]-a[i-1];
    }
    int d=0; int ans=0;
    for(int i=1; i<=n; ++i) {
        int f=1;
        for(int j=i+1; j<=n; ++j) {
            if(a[j]!=a[j-i]) { f=0; break; }
        }
        if(f) { ans++; }
    }
    cout<<ans<<endl;
}


#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int a[maxn];

int main() {
    int n=read();
    for(int i=1; i<=n; ++i) a[i]=read();
    for(int i=n; i; --i) {
        a[i]=a[i]-a[i-1];
    }
    int d=0;
    for(int i=1; i<=n; ++i) {
        int f=1;
        for(int j=i+1; j<=min(2*i,n); ++j) {
            if(a[j-i]!=a[j]) { f=0; break; }
        }
        if(f) { d=i; break; }
    }
    cout<<(n-1)/d+1<<endl;
    for(int i=1; i<=(n-1)/d+1; ++i) printf("%d ", min(d*i,n));
    cout<<endl;
}


#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int a[maxn];

int main() {
    int n=read();
    for(int i=1; i<=n; ++i) a[i]=read();
    for(int i=n; i>1; --i) {
        a[i]=a[i]-a[i-1];
    }
    int d=0;
    vector<int> ans;
    for(int i=1; i<=n; ++i) {
        int f=1;
        for(int j=i+1; j<=n; ++j) {
            if(a[j]!=a[j-i]) { f=0; break; }
        }
        if(f) { ans.push_back(i); }
    }
    cout<<ans.size()<<endl;
    for(int i=0; i<ans.size(); ++i) printf("%d%c", ans[i], " \n"[i==ans.size()-1]);
}


#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int a[maxn];

int main() {
    int n=read();
    for(int i=1; i<=n; ++i) a[i]=read();
    for(int i=n; i; --i) {
        a[i]=a[i]-a[i-1];
    }
    int d=0;
    for(int i=1; i<=n; ++i) {
        int f=1;
        for(int j=i+1; j<=n; ++j) {
            if(a[j-i]!=a[j]) { f=0; break; }
        }
        if(f) { d=i; break; }
    }
    cout<<(n-1)/d+1<<endl;
    for(int i=1; i<=(n-1)/d+1; ++i) printf("%d ", min(d*i,n));
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,n) for(int i=0;i<=n;i++)
#define rep2(i,n) for(int i=n; i>=0; i--)
#define rep3(i,a,b) for(int i=a; i<=b; i++)
#define rep4(i,a,b) for(int i=a; i>=b; i--) // a > b
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define INT(...)                                                                                \
    int __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define LL(...)                                                                                \
    ll __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define STR(...)                                                                                \
    string __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define CHR(...)                                                                                \
    char __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define DBL(...)                                                                                \
    double __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
int scan() { return getchar(); }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T> void scan(vector<T> &);
template <class T> void scan(vector<T> &a) {
    for(auto &i : a) scan(i);
}
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) {
    scan(head);
    IN(tail...);
}
#define TEST                                                                                \
    INT(testcases);                                                                                \
    while(testcases--)

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef map<string,int> msi;
typedef map<string,ll> msl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef unordered_map<string,int> umsi;
typedef unordered_map<string,ll> umsl;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

int mulMod(ll a, ll b) {a*=b;a%=MOD;return (int)a;}
int addMod(int a, int b) {ll c = a + b; if(c >=MOD) c -=MOD; return (int)c;}
void readArray(int *nums, int n) {for(int i=0; i<n; i++) cin>>nums[i];}
void printArray(int *nums, int n) {for(int i=0; i<n; i++) cout<<nums[i]<<" "; cout<<endl;}
bool isprime(ll n) {for(ll i=2; i*i<=n; i++) if(n%i==0) return false; return true;}
bool isvowel(char c) {return c=='A' || c=='E' || c=='I' || c=='O' || c=='U' || c=='a' || c=='e' || c=='i' || c=='o' || c=='u';}
bool cmp(pii x, pii y) {return x.second>y.second;}

int main() {
fast
// TEST {
    INT(n);
    int a[n];
    readArray(a,n);
    rep4(i,n-1,1)
        a[i]=(a[i]-a[i-1]);
    // rep(i,n-1) cout<<a[i]<<endl;
    int m=n;
    rep(i,n-2) {
        bool correct=1;
        for(int j=i+1; j<n; j++) {
            if(a[j]!=a[j%(i+1)]) {
                correct=0; break;
            }
        }
        if(correct) {m=i; break;}
    }
    m++;
    vi ans{m};
    while(ans.back()<n) {
        ans.push_back((ans.size()+1)*m);
    }
    ans.pop_back();
    ans.push_back(n);
    cout<<ans.size()<<"\n";
    for(int x:ans) cout<<x<<" ";
// }
}

/*

2 2
2 5 5

2

*/


#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,n) for(int i=0;i<=n;i++)
#define rep2(i,n) for(int i=n; i>=0; i--)
#define rep3(i,a,b) for(int i=a; i<=b; i++)
#define rep4(i,a,b) for(int i=a; i>=b; i--) // a > b
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define INT(...)                                                                                \
    int __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define LL(...)                                                                                \
    ll __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define STR(...)                                                                                \
    string __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define CHR(...)                                                                                \
    char __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define DBL(...)                                                                                \
    double __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
int scan() { return getchar(); }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T> void scan(vector<T> &);
template <class T> void scan(vector<T> &a) {
    for(auto &i : a) scan(i);
}
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) {
    scan(head);
    IN(tail...);
}
#define TEST                                                                                \
    INT(testcases);                                                                                \
    while(testcases--)

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef map<string,int> msi;
typedef map<string,ll> msl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef unordered_map<string,int> umsi;
typedef unordered_map<string,ll> umsl;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

int mulMod(ll a, ll b) {a*=b;a%=MOD;return (int)a;}
int addMod(int a, int b) {ll c = a + b; if(c >=MOD) c -=MOD; return (int)c;}
void readArray(int *nums, int n) {for(int i=0; i<n; i++) cin>>nums[i];}
void printArray(int *nums, int n) {for(int i=0; i<n; i++) cout<<nums[i]<<" "; cout<<endl;}
bool isprime(ll n) {for(ll i=2; i*i<=n; i++) if(n%i==0) return false; return true;}
bool isvowel(char c) {return c=='A' || c=='E' || c=='I' || c=='O' || c=='U' || c=='a' || c=='e' || c=='i' || c=='o' || c=='u';}
bool cmp(pii x, pii y) {return x.second>y.second;}

int main() {
fast
// TEST {
    INT(n);
    int a[n];
    readArray(a,n);
    rep4(i,n-1,1)
        a[i]=(a[i]-a[i-1]);
    set<int> m;
    m.insert(n);
    rep(i,n-2) {
        bool correct=1;
        for(int j=i+1; j<n; j++) {
            if(a[j]!=a[j%(i+1)]) {
                correct=0; break;
            }
        }
        if(correct) m.insert(i+1);
    }
    cout<<m.size()<<"\n";
    for(int x:m) cout<<x<<" ";
// }
}


#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,n) for(int i=0;i<=n;i++)
#define rep2(i,n) for(int i=n; i>=0; i--)
#define rep3(i,a,b) for(int i=a; i<=b; i++)
#define rep4(i,a,b) for(int i=a; i>=b; i--) // a > b
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define INT(...)                                                                                \
    int __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define LL(...)                                                                                \
    ll __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define STR(...)                                                                                \
    string __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define CHR(...)                                                                                \
    char __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
#define DBL(...)                                                                                \
    double __VA_ARGS__;                                                                                \
    IN(__VA_ARGS__)
int scan() { return getchar(); }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T> void scan(vector<T> &);
template <class T> void scan(vector<T> &a) {
    for(auto &i : a) scan(i);
}
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) {
    scan(head);
    IN(tail...);
}
#define TEST                                                                                \
    INT(testcases);                                                                                \
    while(testcases--)

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef map<string,int> msi;
typedef map<string,ll> msl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef unordered_map<string,int> umsi;
typedef unordered_map<string,ll> umsl;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

int mulMod(ll a, ll b) {a*=b;a%=MOD;return (int)a;}
int addMod(int a, int b) {ll c = a + b; if(c >=MOD) c -=MOD; return (int)c;}
void readArray(int *nums, int n) {for(int i=0; i<n; i++) cin>>nums[i];}
void printArray(int *nums, int n) {for(int i=0; i<n; i++) cout<<nums[i]<<" "; cout<<endl;}
bool isprime(ll n) {for(ll i=2; i*i<=n; i++) if(n%i==0) return false; return true;}
bool isvowel(char c) {return c=='A' || c=='E' || c=='I' || c=='O' || c=='U' || c=='a' || c=='e' || c=='i' || c=='o' || c=='u';}
bool cmp(pii x, pii y) {return x.second>y.second;}

int main() {
fast
// TEST {
    INT(n);
    int a[n];
    readArray(a,n);
    rep4(i,n-1,1)
        a[i]=(a[i]-a[i-1]);
    rep(i,n-1) cout<<a[i]<<endl;
    set<int> m;
    m.insert(n);
    rep(i,n-2) {
        bool correct=1;
        for(int j=i+1; j<n; j++) {
            if(a[j]!=a[j%(i+1)]) {
                correct=0; break;
            }
        }
        if(correct) m.insert(i+1);
    }
    cout<<m.size()<<"\n";
    for(int x:m) cout<<x<<" ";
// }
}

/*

2 2
2 5 5

2

*/


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,i,j,sum=0,t=0,ch=0,k;

    cin>>n;

    vector <int> a(n);
    a[0]=0;
    vector <int> x(n);
    vector <int> f(n);

    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        x[i-1]=a[i]-a[i-1];

    }

    //for(i=0;i<n;i++)
    //    cout <<x[i]<<' ';

    for(k=1;k<n;k++)
    {
        ch=1;
        for(i=k;i<n;i++)
        {
            if(x[i]!=x[i%k])
            {

            ch=0;
                break;
            }

        }
        if(ch==1)
        {
            sum++;
            f[t]=k;
            t++;
            //cout <<k<<' ';
        }
    }
    cout <<sum+1<<'\n';
    for(i=0;i<sum;i++)
    cout<<f[i]<<' ';
    cout <<n;

}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    //ios_base::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    int a[n+1];
    for(int i=1;i<=n;i++)
        scanf("%d",a+i);
    vector<int> ans;

    for(int i=n;i>1;i--)
        a[i]=a[i]-a[i-1];
    bool f = true;
    for(int i=1;i<=n;i++)
    {
        if(a[i]!=a[i+1])
        {
            f = false;
            break;
        }
    }
    if(f)
        ans.push_back(1);
    for(int i=2;i<=n;i++)
    {
        bool flag = true;
        for(int j=i+1;j<=n;j++)
        {
            if(a[j]!=a[j%(i+1)+1])
            {
                flag = false;
                break;
            }
        }
        if(flag)
            ans.push_back(i);
    }

    cout<<ans.size()<<"\n";
    for(int i=0;i<(int)ans.size();i++)
        cout<<ans[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    //ios_base::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    int a[n+1];
    for(int i=1;i<=n;i++)
        scanf("%d",a+i);
    vector<int> ans;

    for(int i=n;i>1;i--)
        a[i]=a[i]-a[i-1];
    bool f = true;
    for(int i=1;i<n;i++)
    {
        if(a[i]!=a[i+1])
        {
            f = false;
            break;
        }
    }
    if(f)
        ans.push_back(1);
    for(int i=2;i<=n;i++)
    {
        bool flag = true;
        for(int j=i+1;j<=n;j++)
        {
            if(a[j]!=a[j%(i+1)+1])
            {
                flag = false;
                break;
            }
        }
        if(flag)
            ans.push_back(i);
    }

    cout<<ans.size()<<"\n";
    for(int i=0;i<(int)ans.size();i++)
        cout<<ans[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    //ios_base::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    int a[n+1];
    for(int i=1;i<=n;i++)
        scanf("%d",a+i);
    vector<int> ans;

    for(int i=n;i>1;i--)
        a[i]=a[i]-a[i-1];
    bool f = true;
    for(int i=1;i<n;i++)
    {
        if(a[i]!=a[i+1])
        {
            f = false;
            break;
        }
    }
    if(f)
        ans.push_back(1);
    for(int i=2;i<=n;i++)
    {
        bool flag = true;
        for(int j=i+1;j<=n;j++)
        {
            if(a[j]!=a[j-i])
            {
                flag = false;
                break;
            }
        }
        if(flag)
            ans.push_back(i);
    }

    cout<<ans.size()<<"\n";
    for(int i=0;i<(int)ans.size();i++)
        cout<<ans[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int a[n+1];
    for(int i=1;i<=n;i++)
        scanf("%d",a+i);
    vector<int> ans;
    a[0] = 0;
    for(int i=1;i<=n;i++)
    {
        bool flag = true;
        for(int j=i+1;j<=n;j++)
        {
            if(a[j]-a[j-1]!=a[j-i]-a[j-i-1])
            {
                flag = false;
                break;
            }
        }
        if(flag)
            ans.push_back(i);
    }

    cout<<ans.size()<<"\n";
    for(int i=0;i<(int)ans.size();i++)
        cout<<ans[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int a[n+1];
    for(int i=1;i<=n;i++)
        scanf("%d",a+i);
    vector<int> ans;

    for(int i=1;i<=n;i++)
    {
        bool flag = true;
        for(int j=i+1;j<=n;j++)
        {
            if(a[j]-a[j-1]!=a[j-i]-a[j-i-1])
            {
                flag = false;
                break;
            }
        }
        if(flag)
            ans.push_back(i);
    }

    cout<<ans.size()<<"\n";
    for(int i=0;i<(int)ans.size();i++)
        cout<<ans[i]<<" ";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;
ll power(ll a, ll b)
{
    ll value = 1;
    while (b)
    {
        if (b & 1)
        {
            value *= a;
        }
        a *= a;
        b /= 2;
    }
    return value;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll b[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    if(n==1){
        cout<<1<<endl<<b[0]<<endl;
        return 0;
    }
    ll a[n] = {0};
    a[0] = b[0];
    for (ll i = 1; i < n; i++)
        a[i] = b[i] - b[i - 1];
    int fg[n+1]={0};
    for (ll i = 1; i <=n-1; i++)
    {
        ll x = 0, k = i;
        for (ll j = i; j < n; j++)
        {
            if (a[j] != a[(x++) % k])
            {
                fg[i] = 1;
                break;
            }

        }
    }
    vector<ll> v;
    for(ll i=1;i<=n;i++){
        if(!fg[i]){
            v.push_back(i);
        }
    }
    cout << v.size() << endl;
    for (auto i : v)
    {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;
ll power(ll a, ll b)
{
    ll value = 1;
    while (b)
    {
        if (b & 1)
        {
            value *= a;
        }
        a *= a;
        b /= 2;
    }
    return value;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll b[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    if(n==1){
        cout<<1<<endl<<1<<endl;
        return 0;
    }
    ll a[n] = {0};
    a[0] = b[0];
    for (ll i = 1; i < n; i++)
        a[i] = b[i] - b[i - 1];
    int fg[n+1]={0};
    for (ll i = 1; i <=n-1; i++)
    {
        ll x = 0, k = i;
        for (ll j = 0; j < n; j++)
        {
            if (a[j] != a[j % k])
            {
                fg[i] = 1;
                break;
            }

        }
    }
    vector<ll> v;
    for(ll i=1;i<=n;i++){
        if(!fg[i]){
            v.push_back(i);
        }
    }
    cout << v.size() << endl;
    for (auto i : v)
    {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}