#include<algorithm>
#include<iostream>
#include<iostream>
using namespace std;
typedef struct {
int start_time;
int use_time;
int end_time;
int key;
}Teacher;
bool cmp(Teacher a,Teacher b)
{
return a.key<b.key;
}
int main()
{
Teacher teacher[2000];
int key[2000];
int N,K;
int i,j;
{
Teacher teacher[2000];
int key[2000];
int N,K;
int i,j;
cin>>N>>K;
for(i=0;i<K;i++)
{
cin>>teacher[i].key>>teacher[i].start_time>>teacher[i].use_time;
teacher[i].end_time=teacher[i].start_time+teacher[i].use_time;
}
for(i=1;i<=N;i++)
{
key[i]=i;
}
for(i=K;i<=1999;i++)
{
teacher[i].key=0;
}
for(i=0;i<K;i++)
{
cin>>teacher[i].key>>teacher[i].start_time>>teacher[i].use_time;
teacher[i].end_time=teacher[i].start_time+teacher[i].use_time;
}
for(i=1;i<=N;i++)
{
key[i]=i;
}
for(i=K;i<=1999;i++)
{
teacher[i].key=0;
}
int time=0;
int MAX=0;
sort(teacher,teacher+K,cmp);
for(i=0;i<K;i++)
if(MAX<teacher[i].end_time)
MAX=teacher[i].end_time;
while(time<=MAX)
{
int position=0;
for(i=0;i<K;i++)
if(teacher[i].end_time==time)
for(j=1;j<=N;j++)
if(key[j]!=-1)
continue;
else
{
key[j]=teacher[i].key;
break;
}
for(i=0;i<K;i++)
if(teacher[i].start_time==time)
for(j=1;j<=N;j++)
if(key[j]==teacher[i].key)
key[j]=-1;
time++;
}
for(i=1;i<N;i++)
cout<<key[i]<<" ";
cout<<key[N]<<endl;
return 0;
}
if(teacher[i].start_time==time)
for(j=1;j<=N;j++)
if(key[j]==teacher[i].key)
key[j]=-1;
time++;
}
for(i=1;i<N;i++)
cout<<key[i]<<" ";
cout<<key[N]<<endl;
return 0;
}