#include<bits/stdc++.h>
#define N 300005
#define rat 4
using namespace std;
struct Node{
int size,val,rev;
Node *lc,*rc;
Node(int s,int v,Node *a,Node *b):size(s),val(v),lc(a),rc(b),rev(){}
Node(){}
}*nul,*rt,*st[N],t[N];
int n,m,l,r,cnt,a[N];
inline void pushup(Node *o){
if(o->lc->size)o->size=o->lc->size+o->rc->size;
}
inline void pushdown(Node *o){
if(o->rev){
o->lc->rev^=;o->rc->rev^=;o->rev^=;
swap(o->lc,o->rc);
}
}
inline Node* newnode(int s,int v,Node *a,Node *b){
return &(*st[cnt++]=Node(s,v,a,b));
}
Node * build(int l,int r){
if(l==r)return newnode(,a[l],nul,nul);
int mid=(l+r)>>;
return newnode(r-l+,a[r],build(l,mid),build(mid+,r));
}
Node* merge(Node *a,Node *b){
pushdown(a);pushdown(b);
if(a->size>b->size*rat)return a->rc=merge(a->rc,b),pushup(a),a;
if(b->size>a->size*rat)return b->lc=merge(a,b->lc),pushup(b),b;
return newnode(a->size+b->size,b->val,a,b);
}
void split(int x,Node *o){
pushdown(o);
if(x>o->lc->size){
split(x-o->lc->size,o->rc);o->lc=merge(o->lc,o->rc->lc);
st[--cnt]=o->rc;o->rc=o->rc->rc;
}
else if(x<o->lc->size){
split(x,o->lc);o->rc=merge(o->lc->rc,o->rc);
st[--cnt]=o->lc;o->lc=o->lc->lc;
}
}
void dfs(Node *o){
pushdown(o);
if(o->size==){if(o->val)printf("%d ",o->val);}
else{dfs(o->lc);dfs(o->rc);}
}
inline int read(){
int f=,x=;char ch;
do{ch=getchar();if(ch=='-')f=-;}while(ch<''||ch>'');
do{x=x*+ch-'';ch=getchar();}while(ch>=''&&ch<='');
return f*x;
}
int main(){
n=read();m=read();
for(int i=;i<=n;i++)a[i]=i;
for(int i=;i<=N;i++)st[i]=&t[i];
nul=new Node(,,,);
rt=build(,n+);
while(m--){
l=read(),r=read();l++;r++;
split(r,rt);split(l-,rt->lc);
rt->lc->rc->rev^=;
}
dfs(rt);
return ;
}
05-25 18:51