#include<bits/stdc++.h>
using namespace std;
int n,k,z[100005];
int main (){
cin>>n>>k;
for(int i=1;i<=n;i++) z[i]=i;
for(int i=1;i<=k;i++){
int a,b,c;cin>>a>>b>>c;
int tmp[b-a+2],t=0;
for(int j=a;j<=b;j++) tmp[++t]=z[j];
if(c<a-1){
for(int j=c+1;j<=a-1;j++) z[j+t]=z[j];
for(int i=c+1,j=1;j<=t;i++,j++) z[i]=tmp[j];
}
else
if(c>a-1){
for(int j=b+1;j<=c;j++) z[j-t]=z[j];
for(int i=c+1-t,j=1;j<=t;i++,j++) z[i]=tmp[j];
}
}
for(int i=1;i<=10;i++){
cout<<z[i]<<'\n';
}
return 0;
}