# include <bits/stdc++.h>
using namespace std ;
const int N = 1e5 + 7 ;
const int INF = 0x3f3f3f3f ;
int rt , ch[N][2] , fa[N] , val[N] , cnt[N] , size[N] , tot , tag[N] ;
inline void upd_size ( int u ) { size[u] = cnt[u] + size[ch[u][0]] + size[ch[u][1]] ; }
inline bool get ( int u ) { return u == ch[fa[u]][1] ; }
inline void push_down ( int u ) {
if ( u && tag[u] ) {
tag[ch[u][0]] ^= 1 ;
tag[ch[u][1]] ^= 1 ;
swap ( ch[u][0] , ch[u][1] ) ;
tag[u] = 0 ;
}
}
inline void _rotate ( int x ) {
int y = fa[x] , z = fa[y] , opt = get ( x ) ;
push_down ( x ) , push_down ( y ) ;
ch[y][opt] = ch[x][opt ^ 1] ;
if ( ch[x][opt ^ 1] ) fa[ch[x][opt ^ 1]] = y ;
ch[x][opt ^ 1] = y ; fa[y] = x ; fa[x] = z ;
if ( z ) ch[z][ get ( y ) ] = x;
upd_size ( y ) , upd_size ( x ) ;
}
inline void Splay ( int x , int to ) {
for ( int f = fa[x] ; f = fa[x] , f != to ; _rotate ( x ) )
if ( fa[f] != to ) _rotate ( get ( x ) == get ( f ) ? f : x ) ;
if ( to == 0 ) rt = x ;
}
inline int find ( int x ) {
int now = rt ;
while ( 1 ) {
push_down(now) ;
if ( x <= size[ch[now][0]] ) now = ch[now][0] ;
else{
x -= size[ch[now][0]] + 1 ;
if ( !x ) return now ;
now = ch[now][1] ;
}
}
}
inline void reverse ( int x , int y ) {
int l = x - 1 , r = y + 1 ;
l = find ( l ) , r = find ( r ) ;
Splay ( l , 0 ) , Splay ( r , l ) ;
tag[ch[ch[rt][1]][0]] ^= 1 ;
}
inline void dfs ( int u ) {
push_down(u) ;
if ( ch[u][0] ) dfs ( ch[u][0] ) ;
if ( val[u] != INF && val[u] != -INF ) cout << val[u] << " " ;
if ( ch[u][1] ) dfs ( ch[u][1] ) ;
}
inline void insert ( int x ) {
if ( !rt ) {
rt = ++ tot ; val[tot] = x ; cnt[tot] = 1 ; size[tot] = 1 ;
return ;
}
int now = rt , f = 0 ;
while ( 1 ) {
f = now , now = ch[now][val[ch[now][0]] < x] ;
if ( !now ) {
val[++tot] = x , cnt[tot] = 1 , size[tot] = 1 , fa[tot] = f , ch[f][val[f] < x] = now ;
upd_size ( f ) ;
Splay ( tot , 0 ) ; break ;
}
}
}
int main () {
int n , m ;
cin >> n >> m ;
insert ( INF ) , insert ( - INF ) ;
for ( int i = 1 ; i <= n ; i++ ) insert(i) ;
while ( m-- ) {
int x , y ;
cin >> x >> y ;
reverse ( x + 1 , y + 1 ) ;
}
cout << rt ;
dfs ( rt ) ;
return 0 ;
}