#include <random>
#include <iostream>
#include <cstdio>
#include <cassert>

#include <ext/rope> // заголовочный файл с rope

using namespace std;
using namespace __gnu_cxx; // пространство имен, в котором находится класс rope и все, что с ним связано

#define all(a) (a).begin(), (a).end()

template<class T>
void out( T a, T b ) {
	printf("struct = ");
	for (; a != b; a++)
		printf("%d ", *a);
	puts("");
}

mt19937 R(239);

int main() {
	ios_base::sync_with_stdio(false);
	int n, m;
	assert(scanf("%d%d", &n, &m) == 2);
	rope<int> v(n, 0); 
	// rope<int> v(n) просто построит rope из одного элемента равного n

	/**
	 v.begin(), v.end()
	 v[i] // O(logn)
	 for (int x : v)
	 */
	out(all(v));
	v[0]; // ok
	// v[0] = 2; <-- error
	
	for (int i = 0; i < n; ++i)
		v.mutable_reference_at(i) = i + 1; // O(logn)
		
	out(all(v));

	for (int i = 0; i < m; ++i)	{
		int l = R() % n;
		int r = R() % n;
		if (l > r) swap(l, r);
		
		auto cur = v.substr(l, r - l + 1); // rope<int> cur
		v.erase(l, r - l + 1); 
		v.insert(v.mutable_begin(), cur); // долго
	}

	out(all(v));
}