#include<bits/stdc++.h>
//#define yamin
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

#define PB push_back
#define F first
#define S second
#define MP make_pair

#define PI acos(-1)
#define EPS 1e-9
#define inf 100000000
#define MOD 1000000007
//#define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
inline ll setBit(ll n, int i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }

int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < EPS; }

//
//debug
#ifdef yamin
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
#else
#define dbg(args...)
#endif // yamin

#define MX 1010000

int ans[MX];

int main () {

    int n, q; scanf ( "%d%d", &n, &q );

    int one = 0, two = 1;

    while ( q-- ) {

            int d; cin >> d;

            if ( d == 1 ) {

                    int x; cin >> x;
                    one += x; one %= n;
                    two += x; two %= n;

            }

            else {

                    if ( one % 2 == 0 ) one++;
                    else one--;

                    if ( two % 2 == 0 ) two++;
                    else two--;

                    one %= n; two %= n;

            }

            if ( one < 0 ) one += n;
            if ( two < 0 ) two += n;

    }
    dbg ( one, two );

    for ( int i = one, j = 1; j <= n; j += 2, i = ( i + 2 ) % n ) ans[i] = j;
    for ( int i = two, j = 2; j <= n; j += 2, i = ( i + 2 ) % n ) ans[i] = j;

    for ( int i = 0; i < n; ++i ) printf ( "%d ", ans[i] );

    return 0;

}


#include<bits/stdc++.h>
//#define yamin
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

#define PB push_back
#define F first
#define S second
#define MP make_pair

#define PI acos(-1)
#define EPS 1e-9
#define inf 100000000
#define MOD 1000000007
//#define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
inline ll setBit(ll n, int i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }

int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < EPS; }

//
//debug
#ifdef yamin
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
#else
#define dbg(args...)
#endif // yamin

#define MX 1010000

int ans[MX];

int main () {

    int n, q; scanf ( "%d%d", &n, &q );

    ll one = 0, two = 1;

    while ( q-- ) {

            int d; scanf ( "%d", &d );

            if ( d == 1 ) {

                    int x; scanf ( "%d", &x );
                    one += x;
                    two += x;

            }

            else {

                    if ( one & 1 ) one++;
                    else one--;

                    if ( two & 1 ) two++;
                    else two--;

            }

    }

    one %= n; two %= n; if ( one < 0 ) one += n; if ( two < 0 ) two += n;
    dbg ( one, two );

    for ( int i = one, j = 1; j <= n; j += 2) {
            ans[i] = j;
            if ( i == n-1 ) i = 0;
            else ++i;
    }
    for ( int i = two, j = 2; j <= n; j += 2 ) {
            ans[i] = j;
            if ( i == n-1 ) i = 0;
            else ++i;
    }

    for ( int i = 0; i < n; ++i ) printf ( "%d ", ans[i] );

    return 0;

}


#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cctype>

#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<algorithm>
#include<stack>

//#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
const int INF = 0x7fffffff;
typedef long long ll;
const double eps = 1e-8;
const double PI = 2 * cos(0.0);
const int MOD = 1000000007;

#define MAXN 100005

int n, q;
int a[MAXN];

int main()
{
	int pos1, pos2;
	int op, opd;
	cin >> n >> q;
	pos1 = 1;
	pos2 = 2;
	while (q--)
	{
		scanf("%d", &op);
		if (op == 1)
		{
			scanf("%d", &opd);

			pos1 += opd;
			pos1 %= n;
			while (pos1 <= 0) pos1 += n;

			pos2 += opd;
			pos2 %= n;
			while (pos2 <= 0) pos2 += n;
		}
		else
		{
			if (pos1 % 2) pos1++;
			else pos1--;
			pos1 %= n;
			while (pos1 <= 0) pos1 += n;

			if (pos2 % 2) pos2++;
			else pos2--;
			pos2 %= n;
			while (pos2 <= 0) pos2 += n;
		}
	}

	int cnt;
	cnt = 1;
	for (int i = pos1;; i += 2, cnt += 2)
	{
		if (i > n)i -= n;
		a[i] = cnt;
		if (cnt == n - 1) break;
	}

	cnt = 2;
	for (int i = pos2;; i += 2, cnt += 2)
	{
		if (i > n)i -= n;
		a[i] = cnt;
		if (cnt == n) break;
	}

	for (int i = 1; i <= n; i++)
	{
		cout << a[i] << ' ';
	}
	cout << endl;

	//system("pause");

}


#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cctype>

#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<algorithm>
#include<stack>

//#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
const int INF = 0x7fffffff;
typedef long long ll;
const double eps = 1e-8;
const double PI = 2 * cos(0.0);
const int MOD = 1000000007;

#define MAXN 100005

int n, q;
int a[MAXN];

int main()
{
	int pos1, pos2;
	int op, opd;
	cin >> n >> q;
	pos1 = 1;
	pos2 = 2;
	while (q--)
	{
		scanf("%d", &op);
		if (op == 1)
		{
			scanf("%d", &opd);
			pos1 += opd;
			if (pos1 <= 0) pos1 += n;
			else if (pos1 > n) pos1 -= n;
			pos2 += opd;
			if (pos2 <= 0) pos2 += n;
			else if (pos2 > n) pos2 -= n;
		}
		else
		{
			if (pos1 % 2) pos1++;
			else pos1--;
			if (pos2 % 2) pos2++;
			else pos2--;
			if (pos1 <= 0) pos1 += n;
			else if (pos1 > n) pos1 -= n;
			if (pos2 <= 0) pos2 += n;
			else if (pos2 > n) pos2 -= n;
		}
	}

	int cnt;
	cnt = 1;
	for (int i = pos1;; i += 2, cnt += 2)
	{
		if (i > n)i -= n;
		a[i] = cnt;
		if (cnt == n - 1) break;
	}

	cnt = 2;
	for (int i = pos2;; i += 2, cnt += 2)
	{
		if (i > n)i -= n;
		a[i] = cnt;
		if (cnt == n) break;
	}

	for (int i = 1; i <= n; i++)
	{
		cout << a[i] << ' ';
	}
	cout << endl;

	//system("pause");

}


#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cctype>

#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<algorithm>
#include<stack>

//#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
const int INF = 0x7fffffff;
typedef long long ll;
const double eps = 1e-8;
const double PI = 2 * cos(0.0);
const int MOD = 1000000007;

#define MAXN 100005

int n, q;
int a[MAXN];

int main()
{
	int pos1, pos2;
	int op, opd;
	cin >> n >> q;
	pos1 = 1;
	pos2 = 2;
	while (q--)
	{
		cin >> op;
		if (op == 1)
		{
			cin >> opd;
			pos1 += opd;
			if (pos1 <= 0) pos1 += n;
			if (pos1 > n) pos1 -= n;
			pos2 += opd;
			if (pos2 <= 0) pos2 += n;
			if (pos2 > n) pos2 -= n;
		}
		else
		{
			if (pos1 % 2) pos1++;
			else pos1--;
			if (pos2 % 2) pos2++;
			else pos2--;
			if (pos1 <= 0) pos1 += n;
			if (pos1 > n) pos1 -= n;
			if (pos2 <= 0) pos2 += n;
			if (pos2 > n) pos2 -= n;
		}
	}

	int cnt;
	cnt = 1;
	for (int i = pos1;; i += 2, cnt += 2)
	{
		if (i > n)i -= n;
		a[i] = cnt;
		if (cnt == n - 1) break;
	}

	cnt = 2;
	for (int i = pos2;; i += 2, cnt += 2)
	{
		if (i > n)i -= n;
		a[i] = cnt;
		if (cnt == n) break;
	}

	for (int i = 1; i <= n; i++)
	{
		cout << a[i] << ' ';
	}
	cout << endl;

	//system("pause");

}


#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cctype>

#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<algorithm>
#include<stack>

//#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
const int INF = 0x7fffffff;
typedef long long ll;
const double eps = 1e-8;
const double PI = 2 * cos(0.0);
const int MOD = 1000000007;

#define MAXN 1000005

int n, q;
int a[MAXN];

int main()
{
	int pos1, pos2;
	int op, opd;
	cin >> n >> q;
	pos1 = 1;
	pos2 = 2;
	while (q--)
	{
		scanf("%d", &op);
		if (op == 1)
		{
			scanf("%d", &opd);

			pos1 += opd;
			pos1 %= n;
			while (pos1 <= 0) pos1 += n;

			pos2 += opd;
			pos2 %= n;
			while (pos2 <= 0) pos2 += n;
		}
		else
		{
			if (pos1 % 2) pos1++;
			else pos1--;
			pos1 %= n;
			while (pos1 <= 0) pos1 += n;

			if (pos2 % 2) pos2++;
			else pos2--;
			pos2 %= n;
			while (pos2 <= 0) pos2 += n;
		}
	}

	int cnt;
	cnt = 1;
	for (int i = pos1;; i += 2, cnt += 2)
	{
		if (i > n)i -= n;
		a[i] = cnt;
		if (cnt == n - 1) break;
	}

	cnt = 2;
	for (int i = pos2;; i += 2, cnt += 2)
	{
		if (i > n)i -= n;
		a[i] = cnt;
		if (cnt == n) break;
	}

	for (int i = 1; i <= n; i++)
	{
		cout << a[i] << ' ';
	}
	cout << endl;

	//system("pause");

}


#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cctype>

#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<algorithm>
#include<stack>

//#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
const int INF = 0x7fffffff;
typedef long long ll;
const double eps = 1e-8;
const double PI = 2 * cos(0.0);
const int MOD = 1000000007;

#define MAXN 100005

int n, q;
int a[MAXN];

int main()
{
	int pos1, pos2;
	int op, opd;
	cin >> n >> q;
	pos1 = 1;
	pos2 = 2;
	while (q--)
	{

		cin >> op;
		if (op == 1)
		{
			cin >> opd;
			pos1 += opd;
			if (pos1 <= 0) pos1 += n;
			if (pos1 > n) pos1 -= n;
			pos2 += opd;
			if (pos2 <= 0) pos2 += n;
			if (pos2 > n) pos2 -= n;
		}
		else
		{
			swap(pos1, pos2);
		}
	}
	int cnt;

	cnt = 1;
	for (int i = pos1;; i += 2, cnt += 2)
	{
		if (i > n)i -= n;
		a[i] = cnt;
		if (cnt == n - 1) break;
	}

	cnt = 2;
	for (int i = pos2;; i += 2, cnt += 2)
	{
		if (i > n)i -= n;
		a[i] = cnt;
		if (cnt == n) break;
	}

	for (int i = 1; i <= n; i++)
	{
		cout << a[i] << ' ';
	}
	cout << endl;

	//system("pause");

}


#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cctype>

#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<algorithm>
#include<stack>

//#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
const int INF = 0x7fffffff;
typedef long long ll;
const double eps = 1e-8;
const double PI = 2 * cos(0.0);
const int MOD = 1000000007;

#define MAXN 100005

int n, q;
int a[MAXN];

int main()
{
	int pos1, pos2;
	int op, opd;
	cin >> n >> q;
	pos1 = 1;
	pos2 = 2;
	while (q--)
	{
		scanf("%d", &op);
		if (op == 1)
		{
			scanf("%d", &opd);

			pos1 += opd;
			while (pos1 <= 0) pos1 += n;
			pos1 %= n;

			pos2 += opd;
			while (pos2 <= 0) pos2 += n;
			pos2 %= n;
		}
		else
		{
			if (pos1 % 2) pos1++;
			else pos1--;
			while (pos1 <= 0) pos1 += n;
			pos1 %= n;

			if (pos2 % 2) pos2++;
			else pos2--;
			while (pos2 <= 0) pos2 += n;
			pos2 %= n;
		}
	}

	int cnt;
	cnt = 1;
	for (int i = pos1;; i += 2, cnt += 2)
	{
		if (i > n)i -= n;
		a[i] = cnt;
		if (cnt == n - 1) break;
	}

	cnt = 2;
	for (int i = pos2;; i += 2, cnt += 2)
	{
		if (i > n)i -= n;
		a[i] = cnt;
		if (cnt == n) break;
	}

	for (int i = 1; i <= n; i++)
	{
		cout << a[i] << ' ';
	}
	cout << endl;

	//system("pause");

}


#include <bits/stdc++.h>

using namespace std;

typedef char i1;
typedef unsigned char u1;
typedef short i2;
typedef unsigned short u2;
typedef int i4;
typedef unsigned int u4;
typedef long long i8;
typedef unsigned long long u8;
typedef float f4;
typedef double f8;

#define u2max ((u2)(~0U))
#define i2max ((i2)(u2max>>1))
#define i2min ((i2)(-i2max - 1))
#define u4max ((u4)(~0U))
#define i4max ((i4)(u4max>>1))
#define i4min (-i4max - 1)
#define u8max ((u8)(~0ULL))
#define i8max ((i8)(u8max>>1))
#define i8min (-i8max - 1)
#define f4min (numeric_limits<float>::min())
#define f4max (numeric_limits<float>::max())
#define f8min (numeric_limits<double>::min())
#define f8max (numeric_limits<double>::max())
#define f8inf (numeric_limits<f8>::infinity())
#define f4inf (numeric_limits<f4>::infinity())
#define inf f8inf

const f8 PI = 3.1415926;

template <typename T>
T gcd(T a, T b) { while (b){ T c = a % b; a = b; b = c; } return a; }
template <typename T>
T lcm(T a, T b){ assert(a/gcd(a, b) <= numeric_limits<T>::max()/b); return a * (b / gcd(a, b)); }
class out { public:
    template <typename T> out &operator()(const T &t){ cout << t << ' '; return *this; }
    template <typename T1, typename T2> out &operator()(const pair<T1, T2> &t){ cout << '(' << t.first << ',' << t.second << ')' << ' '; return *this; }};
template <typename iter> inline void print_(iter beg, iter end){ for_each(beg, end, out()); cout << endl; }
template<typename T> inline void print_(const T &t) { cout << t << endl; }
inline void print_(const char *fmt, ...) { va_list va; va_start(va, fmt); vprintf(fmt, va); va_end(va); }
//template<typename T, u4 M> inline void print_(const T (&t)[M] ) { for (u4 i = 0; i < M; ++i) { cout << t[i] << ' '; } cout << endl; }
//template<typename T, u4 M> inline void print_(const T (&t)[M], u4 c) { for (u4 i = 0; i < c; ++i) { cout << t[i] << ' '; } cout << endl; }
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N] ) { for (u4 i = 0; i < M; ++i) { for (u4 j = 0; j < N; ++j) { cout << t[i][j] << ' '; } cout << endl; }}
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N], u4 r, u4 c) { for (u4 i = 0; i < r; ++i) { for (u4 j = 0; j < c; ++j) { cout << t[i][j] << ' '; } cout << endl; } }
template<typename T> inline i4 BKDRHash(const T *str) { register i4 hash = 0; while (i4 ch = (i4)*str++) { hash = hash * 131 + ch; } return hash; }
inline u8 powxy(u8 x, i4 y = 2) { u8 r; for (r = 1; y > 0; --y) r *= x; return r; }
inline u8 factorial(u8 n) { u8 r; for (r = 1; n > 0; --n) r *= n; return r; }
inline u8 permutation(u8 n, u8 k) { u8 r = 1; while (k--) r *= n--; return r; }
inline u8 combination(u8 n, u8 k) { return permutation(n, k) / factorial(k); }

#define FILE
#define TRACE
#if defined DEBUG && defined TRACE
    #define print print_
#else
    #define print
#endif
i4 n, q, a[1000000];
i8 s1;
i4 s2;
void shift(i8 x)
{
    i4 y = x % n;
    if (y >= 0)
        rotate(a, a+n-y, a+n);
    else
        rotate(a, a-y, a+n); // y<0
}
void swap()
{
    for (i4 *p = a; p < a+n; p += 2)
        iter_swap(p, p+1);
}
#ifndef NOMAIN
int main()
{
#if defined DEBUG && defined FILE
    freopen("in.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &q);
    for (i4 i = 0; i < n; ++i) a[i] = i + 1;
    for (i4 i = 0; i < q; ++i)
    {
        i4 c, x;
        scanf("%d", &c);
        if (c == 1)
        {
            if (s2)
            {
                if (s1 % 2)
                {
                    shift(s1);
                    s1 = 0;
                    swap();
                    s2 = 0;
                }
                else
                {
                    swap();
                    s2 = 0;
                }
            }
            scanf("%d", &x);
            s1 += x;
        }
        else
        {
            s2 = 1 ^ s2;
        }
    }
    shift(s1);
    if (s2) swap();
    for (i4 i = 0; i < n; ++i) printf("%d ", a[i]);
    return 0;
}
#endif


#include <bits/stdc++.h>

using namespace std;

typedef char i1;
typedef unsigned char u1;
typedef short i2;
typedef unsigned short u2;
typedef int i4;
typedef unsigned int u4;
typedef long long i8;
typedef unsigned long long u8;
typedef float f4;
typedef double f8;

#define u2max ((u2)(~0U))
#define i2max ((i2)(u2max>>1))
#define i2min ((i2)(-i2max - 1))
#define u4max ((u4)(~0U))
#define i4max ((i4)(u4max>>1))
#define i4min (-i4max - 1)
#define u8max ((u8)(~0ULL))
#define i8max ((i8)(u8max>>1))
#define i8min (-i8max - 1)
#define f4min (numeric_limits<float>::min())
#define f4max (numeric_limits<float>::max())
#define f8min (numeric_limits<double>::min())
#define f8max (numeric_limits<double>::max())
#define f8inf (numeric_limits<f8>::infinity())
#define f4inf (numeric_limits<f4>::infinity())
#define inf f8inf

const f8 PI = 3.1415926;

template <typename T>
T gcd(T a, T b) { while (b){ T c = a % b; a = b; b = c; } return a; }
template <typename T>
T lcm(T a, T b){ assert(a/gcd(a, b) <= numeric_limits<T>::max()/b); return a * (b / gcd(a, b)); }
class out { public:
    template <typename T> out &operator()(const T &t){ cout << t << ' '; return *this; }
    template <typename T1, typename T2> out &operator()(const pair<T1, T2> &t){ cout << '(' << t.first << ',' << t.second << ')' << ' '; return *this; }};
template <typename iter> inline void print_(iter beg, iter end){ for_each(beg, end, out()); cout << endl; }
template<typename T> inline void print_(const T &t) { cout << t << endl; }
inline void print_(const char *fmt, ...) { va_list va; va_start(va, fmt); vprintf(fmt, va); va_end(va); }
//template<typename T, u4 M> inline void print_(const T (&t)[M] ) { for (u4 i = 0; i < M; ++i) { cout << t[i] << ' '; } cout << endl; }
//template<typename T, u4 M> inline void print_(const T (&t)[M], u4 c) { for (u4 i = 0; i < c; ++i) { cout << t[i] << ' '; } cout << endl; }
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N] ) { for (u4 i = 0; i < M; ++i) { for (u4 j = 0; j < N; ++j) { cout << t[i][j] << ' '; } cout << endl; }}
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N], u4 r, u4 c) { for (u4 i = 0; i < r; ++i) { for (u4 j = 0; j < c; ++j) { cout << t[i][j] << ' '; } cout << endl; } }
template<typename T> inline i4 BKDRHash(const T *str) { register i4 hash = 0; while (i4 ch = (i4)*str++) { hash = hash * 131 + ch; } return hash; }
inline u8 powxy(u8 x, i4 y = 2) { u8 r; for (r = 1; y > 0; --y) r *= x; return r; }
inline u8 factorial(u8 n) { u8 r; for (r = 1; n > 0; --n) r *= n; return r; }
inline u8 permutation(u8 n, u8 k) { u8 r = 1; while (k--) r *= n--; return r; }
inline u8 combination(u8 n, u8 k) { return permutation(n, k) / factorial(k); }

#define FILE
#define TRACE
#if defined DEBUG && defined TRACE
    #define print print_
#else
    #define print
#endif
i4 n, q, a[1000000], b;
i8 s1;
i4 s2;
inline void shift(i8 y)
{
    b = (b-y) % n;
    if (b < 0) b = n + b;
}
inline void swap()
{
    for (i4 i = b; i < b+n; i+=2)
        swap(a[i%n], a[(i+1)%n]);
}
#ifndef NOMAIN
int main()
{
#if defined DEBUG && defined FILE
    freopen("in.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &q);
    for (i4 i = 0; i < n; ++i) a[i] = i + 1;
    for (i4 i = 0; i < q; ++i)
    {
        i4 c, x;
        scanf("%d", &c);
        if (c == 1)
        {
            if (s2)
            {
                if (s1 % 2)
                {
                    shift(s1);
                    s1 = 0;
                }
                swap();
                s2 = 0;
            }
            scanf("%d", &x);
            s1 = (s1+x)%n;
        }
        else
        {
            s2 = 1 ^ s2;
        }
        print(a, a+n);
    }
    shift(s1);
    if (s2) swap();
    for (i4 i = b; i < b+n; ++i)
        printf("%d ", a[i%n]);
    return 0;
}
#endif


#include <bits/stdc++.h>

using namespace std;

typedef char i1;
typedef unsigned char u1;
typedef short i2;
typedef unsigned short u2;
typedef int i4;
typedef unsigned int u4;
typedef long long i8;
typedef unsigned long long u8;
typedef float f4;
typedef double f8;

#define u2max ((u2)(~0U))
#define i2max ((i2)(u2max>>1))
#define i2min ((i2)(-i2max - 1))
#define u4max ((u4)(~0U))
#define i4max ((i4)(u4max>>1))
#define i4min (-i4max - 1)
#define u8max ((u8)(~0ULL))
#define i8max ((i8)(u8max>>1))
#define i8min (-i8max - 1)
#define f4min (numeric_limits<float>::min())
#define f4max (numeric_limits<float>::max())
#define f8min (numeric_limits<double>::min())
#define f8max (numeric_limits<double>::max())
#define f8inf (numeric_limits<f8>::infinity())
#define f4inf (numeric_limits<f4>::infinity())
#define inf f8inf

const f8 PI = 3.1415926;

template <typename T>
T gcd(T a, T b) { while (b){ T c = a % b; a = b; b = c; } return a; }
template <typename T>
T lcm(T a, T b){ assert(a/gcd(a, b) <= numeric_limits<T>::max()/b); return a * (b / gcd(a, b)); }
class out { public:
    template <typename T> out &operator()(const T &t){ cout << t << ' '; return *this; }
    template <typename T1, typename T2> out &operator()(const pair<T1, T2> &t){ cout << '(' << t.first << ',' << t.second << ')' << ' '; return *this; }};
template <typename iter> inline void print_(iter beg, iter end){ for_each(beg, end, out()); cout << endl; }
template<typename T> inline void print_(const T &t) { cout << t << endl; }
inline void print_(const char *fmt, ...) { va_list va; va_start(va, fmt); vprintf(fmt, va); va_end(va); }
//template<typename T, u4 M> inline void print_(const T (&t)[M] ) { for (u4 i = 0; i < M; ++i) { cout << t[i] << ' '; } cout << endl; }
//template<typename T, u4 M> inline void print_(const T (&t)[M], u4 c) { for (u4 i = 0; i < c; ++i) { cout << t[i] << ' '; } cout << endl; }
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N] ) { for (u4 i = 0; i < M; ++i) { for (u4 j = 0; j < N; ++j) { cout << t[i][j] << ' '; } cout << endl; }}
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N], u4 r, u4 c) { for (u4 i = 0; i < r; ++i) { for (u4 j = 0; j < c; ++j) { cout << t[i][j] << ' '; } cout << endl; } }
template<typename T> inline i4 BKDRHash(const T *str) { register i4 hash = 0; while (i4 ch = (i4)*str++) { hash = hash * 131 + ch; } return hash; }
inline u8 powxy(u8 x, i4 y = 2) { u8 r; for (r = 1; y > 0; --y) r *= x; return r; }
inline u8 factorial(u8 n) { u8 r; for (r = 1; n > 0; --n) r *= n; return r; }
inline u8 permutation(u8 n, u8 k) { u8 r = 1; while (k--) r *= n--; return r; }
inline u8 combination(u8 n, u8 k) { return permutation(n, k) / factorial(k); }

#define FILE
#define TRACE
#if defined DEBUG && defined TRACE
    #define print print_
#else
    #define print
#endif
i4 n, q, a[1000000], s2;
i8 s1, s3;
void shift(i8 x)
{
    i4 y = x % n;
    if (x >= 0)
        rotate(a, a+n-y, a+n);
    else
        rotate(a, a+y, a+n);
}
void swap(i4 x)
{
    if (x % 2)
    {
        for (i4 *p = a; p < a+n; p += 2)
            iter_swap(p, p+1);
    }
}
#ifndef NOMAIN
int main()
{
#if defined DEBUG && defined FILE
    freopen("in.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &q);
    for (i4 i = 0; i < n; ++i) a[i] = i + 1;
    for (i4 i = 0; i < q; ++i)
    {
        i4 c, x;
        scanf("%d", &c);
        if (c == 1)
        {
            scanf("%d", &x);
            if (x % 2)
            {
                shift(s1);
                s1 = 0;
                swap(s2);
                s2 = 0;
                s3 += x;
            }
            else
            {
                shift(s3);
                s3 = 0;
                s1 += x;
            }
        }
        else
        {
            shift(s3);
            s3 = 0;
            ++s2;
        }
    }
    shift(s1);
    swap(s2);
    shift(s3);
    for (i4 i = 0; i < n; ++i) printf("%d ", a[i]);
    return 0;
}
#endif


#include <bits/stdc++.h>

using namespace std;

typedef char i1;
typedef unsigned char u1;
typedef short i2;
typedef unsigned short u2;
typedef int i4;
typedef unsigned int u4;
typedef long long i8;
typedef unsigned long long u8;
typedef float f4;
typedef double f8;

#define u2max ((u2)(~0U))
#define i2max ((i2)(u2max>>1))
#define i2min ((i2)(-i2max - 1))
#define u4max ((u4)(~0U))
#define i4max ((i4)(u4max>>1))
#define i4min (-i4max - 1)
#define u8max ((u8)(~0ULL))
#define i8max ((i8)(u8max>>1))
#define i8min (-i8max - 1)
#define f4min (numeric_limits<float>::min())
#define f4max (numeric_limits<float>::max())
#define f8min (numeric_limits<double>::min())
#define f8max (numeric_limits<double>::max())
#define f8inf (numeric_limits<f8>::infinity())
#define f4inf (numeric_limits<f4>::infinity())
#define inf f8inf

const f8 PI = 3.1415926;

template <typename T>
T gcd(T a, T b) { while (b){ T c = a % b; a = b; b = c; } return a; }
template <typename T>
T lcm(T a, T b){ assert(a/gcd(a, b) <= numeric_limits<T>::max()/b); return a * (b / gcd(a, b)); }
class out { public:
    template <typename T> out &operator()(const T &t){ cout << t << ' '; return *this; }
    template <typename T1, typename T2> out &operator()(const pair<T1, T2> &t){ cout << '(' << t.first << ',' << t.second << ')' << ' '; return *this; }};
template <typename iter> inline void print_(iter beg, iter end){ for_each(beg, end, out()); cout << endl; }
template<typename T> inline void print_(const T &t) { cout << t << endl; }
inline void print_(const char *fmt, ...) { va_list va; va_start(va, fmt); vprintf(fmt, va); va_end(va); }
//template<typename T, u4 M> inline void print_(const T (&t)[M] ) { for (u4 i = 0; i < M; ++i) { cout << t[i] << ' '; } cout << endl; }
//template<typename T, u4 M> inline void print_(const T (&t)[M], u4 c) { for (u4 i = 0; i < c; ++i) { cout << t[i] << ' '; } cout << endl; }
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N] ) { for (u4 i = 0; i < M; ++i) { for (u4 j = 0; j < N; ++j) { cout << t[i][j] << ' '; } cout << endl; }}
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N], u4 r, u4 c) { for (u4 i = 0; i < r; ++i) { for (u4 j = 0; j < c; ++j) { cout << t[i][j] << ' '; } cout << endl; } }
template<typename T> inline i4 BKDRHash(const T *str) { register i4 hash = 0; while (i4 ch = (i4)*str++) { hash = hash * 131 + ch; } return hash; }
inline u8 powxy(u8 x, i4 y = 2) { u8 r; for (r = 1; y > 0; --y) r *= x; return r; }
inline u8 factorial(u8 n) { u8 r; for (r = 1; n > 0; --n) r *= n; return r; }
inline u8 permutation(u8 n, u8 k) { u8 r = 1; while (k--) r *= n--; return r; }
inline u8 combination(u8 n, u8 k) { return permutation(n, k) / factorial(k); }

#define FILE
#define TRACE
#if defined DEBUG && defined TRACE
    #define print print_
#else
    #define print
#endif
i4 n, q, a[1000000], b;
i4 s1;
i4 s2;
inline void shift(i4 y)
{
    b = (b-y) % n;
    if (b < 0) b = n + b;
}
inline void swap()
{
    for (i4 i = b; i < b+n; i += 2)
        swap(a[i%n], a[(i+1)%n]);
}
#ifndef NOMAIN
int main()
{
#if defined DEBUG && defined FILE
    freopen("in.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &q);
    for (i4 i = 0; i < n; ++i) a[i] = i + 1;
    for (i4 i = 0; i < q; ++i)
    {
        i4 c, x;
        scanf("%d", &c);
        if (c == 1)
        {
            if (s2)
            {
                if (s1 % 2)
                {
                    shift(s1);
                    s1 = 0;
                }
                //swap();
                s2 = 0;
            }
            scanf("%d", &x);
            s1 = (s1+x)%n;
        }
        else
        {
            s2 = 1 ^ s2;
        }
        print(a, a+n);
    }
    shift(s1);
    if (s2) swap();
    for (i4 i = b; i < b+n; ++i)
        printf("%d ", a[i%n]);
    return 0;
}
#endif


#include <bits/stdc++.h>

using namespace std;

typedef char i1;
typedef unsigned char u1;
typedef short i2;
typedef unsigned short u2;
typedef int i4;
typedef unsigned int u4;
typedef long long i8;
typedef unsigned long long u8;
typedef float f4;
typedef double f8;

#define u2max ((u2)(~0U))
#define i2max ((i2)(u2max>>1))
#define i2min ((i2)(-i2max - 1))
#define u4max ((u4)(~0U))
#define i4max ((i4)(u4max>>1))
#define i4min (-i4max - 1)
#define u8max ((u8)(~0ULL))
#define i8max ((i8)(u8max>>1))
#define i8min (-i8max - 1)
#define f4min (numeric_limits<float>::min())
#define f4max (numeric_limits<float>::max())
#define f8min (numeric_limits<double>::min())
#define f8max (numeric_limits<double>::max())
#define f8inf (numeric_limits<f8>::infinity())
#define f4inf (numeric_limits<f4>::infinity())
#define inf f8inf

const f8 PI = 3.1415926;

template <typename T>
T gcd(T a, T b) { while (b){ T c = a % b; a = b; b = c; } return a; }
template <typename T>
T lcm(T a, T b){ assert(a/gcd(a, b) <= numeric_limits<T>::max()/b); return a * (b / gcd(a, b)); }
class out { public:
    template <typename T> out &operator()(const T &t){ cout << t << ' '; return *this; }
    template <typename T1, typename T2> out &operator()(const pair<T1, T2> &t){ cout << '(' << t.first << ',' << t.second << ')' << ' '; return *this; }};
template <typename iter> inline void print_(iter beg, iter end){ for_each(beg, end, out()); cout << endl; }
template<typename T> inline void print_(const T &t) { cout << t << endl; }
inline void print_(const char *fmt, ...) { va_list va; va_start(va, fmt); vprintf(fmt, va); va_end(va); }
//template<typename T, u4 M> inline void print_(const T (&t)[M] ) { for (u4 i = 0; i < M; ++i) { cout << t[i] << ' '; } cout << endl; }
//template<typename T, u4 M> inline void print_(const T (&t)[M], u4 c) { for (u4 i = 0; i < c; ++i) { cout << t[i] << ' '; } cout << endl; }
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N] ) { for (u4 i = 0; i < M; ++i) { for (u4 j = 0; j < N; ++j) { cout << t[i][j] << ' '; } cout << endl; }}
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N], u4 r, u4 c) { for (u4 i = 0; i < r; ++i) { for (u4 j = 0; j < c; ++j) { cout << t[i][j] << ' '; } cout << endl; } }
template<typename T> inline i4 BKDRHash(const T *str) { register i4 hash = 0; while (i4 ch = (i4)*str++) { hash = hash * 131 + ch; } return hash; }
inline u8 powxy(u8 x, i4 y = 2) { u8 r; for (r = 1; y > 0; --y) r *= x; return r; }
inline u8 factorial(u8 n) { u8 r; for (r = 1; n > 0; --n) r *= n; return r; }
inline u8 permutation(u8 n, u8 k) { u8 r = 1; while (k--) r *= n--; return r; }
inline u8 combination(u8 n, u8 k) { return permutation(n, k) / factorial(k); }

#define FILE
#define TRACE
#if defined DEBUG && defined TRACE
    #define print print_
#else
    #define print
#endif
i4 n, q;
list<i4> a;
i8 s1;
i4 s2;
void shift(i8 x)
{
    i4 y = x % n;
    list<i4>::iterator iter = a.begin();
    if (y >= 0)
    {
        advance(iter, n-y);
        a.splice(a.begin(), a, iter, a.end());
    }
    else
    {
        advance(iter, -y); // y<0
        a.splice(a.begin(), a, iter, a.end());
    }
}
void swap()
{
    for (list<i4>::iterator iter = a.begin(); iter != a.end(); advance(iter, 2))
        iter_swap(iter, ++iter);
}
#ifndef NOMAIN
int main()
{
#if defined DEBUG && defined FILE
    freopen("in.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &q);
    for (i4 i = 0; i < n; ++i) a.push_back(i + 1);
    for (i4 i = 0; i < q; ++i)
    {
        i4 c, x;
        scanf("%d", &c);
        if (c == 1)
        {
            if (s2)
            {
                if (s1 % 2)
                {
                    shift(s1);
                    s1 = 0;
                    swap();
                    s2 = 0;
                }
                else
                {
                    swap();
                    s2 = 0;
                }
            }
            scanf("%d", &x);
            s1 += x;
        }
        else
        {
            s2 = 1 ^ s2;
        }
    }
    shift(s1);
    if (s2) swap();
    for (list<i4>::iterator iter = a.begin(); iter != a.end(); ++iter)
        printf("%d ", *iter);
    return 0;
}
#endif


#include <bits/stdc++.h>

using namespace std;

typedef char i1;
typedef unsigned char u1;
typedef short i2;
typedef unsigned short u2;
typedef int i4;
typedef unsigned int u4;
typedef long long i8;
typedef unsigned long long u8;
typedef float f4;
typedef double f8;

#define u2max ((u2)(~0U))
#define i2max ((i2)(u2max>>1))
#define i2min ((i2)(-i2max - 1))
#define u4max ((u4)(~0U))
#define i4max ((i4)(u4max>>1))
#define i4min (-i4max - 1)
#define u8max ((u8)(~0ULL))
#define i8max ((i8)(u8max>>1))
#define i8min (-i8max - 1)
#define f4min (numeric_limits<float>::min())
#define f4max (numeric_limits<float>::max())
#define f8min (numeric_limits<double>::min())
#define f8max (numeric_limits<double>::max())
#define f8inf (numeric_limits<f8>::infinity())
#define f4inf (numeric_limits<f4>::infinity())
#define inf f8inf

const f8 PI = 3.1415926;

template <typename T>
T gcd(T a, T b) { while (b){ T c = a % b; a = b; b = c; } return a; }
template <typename T>
T lcm(T a, T b){ assert(a/gcd(a, b) <= numeric_limits<T>::max()/b); return a * (b / gcd(a, b)); }
class out { public:
    template <typename T> out &operator()(const T &t){ cout << t << ' '; return *this; }
    template <typename T1, typename T2> out &operator()(const pair<T1, T2> &t){ cout << '(' << t.first << ',' << t.second << ')' << ' '; return *this; }};
template <typename iter> inline void print_(iter beg, iter end){ for_each(beg, end, out()); cout << endl; }
template<typename T> inline void print_(const T &t) { cout << t << endl; }
inline void print_(const char *fmt, ...) { va_list va; va_start(va, fmt); vprintf(fmt, va); va_end(va); }
//template<typename T, u4 M> inline void print_(const T (&t)[M] ) { for (u4 i = 0; i < M; ++i) { cout << t[i] << ' '; } cout << endl; }
//template<typename T, u4 M> inline void print_(const T (&t)[M], u4 c) { for (u4 i = 0; i < c; ++i) { cout << t[i] << ' '; } cout << endl; }
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N] ) { for (u4 i = 0; i < M; ++i) { for (u4 j = 0; j < N; ++j) { cout << t[i][j] << ' '; } cout << endl; }}
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N], u4 r, u4 c) { for (u4 i = 0; i < r; ++i) { for (u4 j = 0; j < c; ++j) { cout << t[i][j] << ' '; } cout << endl; } }
template<typename T> inline i4 BKDRHash(const T *str) { register i4 hash = 0; while (i4 ch = (i4)*str++) { hash = hash * 131 + ch; } return hash; }
inline u8 powxy(u8 x, i4 y = 2) { u8 r; for (r = 1; y > 0; --y) r *= x; return r; }
inline u8 factorial(u8 n) { u8 r; for (r = 1; n > 0; --n) r *= n; return r; }
inline u8 permutation(u8 n, u8 k) { u8 r = 1; while (k--) r *= n--; return r; }
inline u8 combination(u8 n, u8 k) { return permutation(n, k) / factorial(k); }

#define FILE
#define TRACE
#if defined DEBUG && defined TRACE
    #define print print_
#else
    #define print
#endif
i4 n, q, a[1000000], b;
i8 s1;
i4 s2;
inline void shift(i8 y)
{
    b = (b-y) % n;
    if (b < 0) b = n + b;
}
inline void swap()
{
    for (i4 i = b; i < b+n; i+=2)
        swap(a[i%n], a[(i+1)%n]);
}
#ifndef NOMAIN
int main()
{
#if defined DEBUG && defined FILE
    freopen("in.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &q);
    for (i4 i = 0; i < n; ++i) a[i] = i + 1;
    for (i4 i = 0; i < q; ++i)
    {
        i4 c, x;
        scanf("%d", &c);
        if (c == 1)
        {
            if (s2)
            {
                if (s1 % 2)
                {
                    shift(s1);
                    s1 = 0;
                }
                swap();
                s2 = 0;
            }
            scanf("%d", &x);
            s1 += x;
        }
        else
        {
            s2 = 1 ^ s2;
        }
        print(a, a+n);
    }
    shift(s1);
    if (s2) swap();
    for (i4 i = b; i < b+n; ++i)
        printf("%d ", a[i%n]);
    return 0;
}
#endif


#include <bits/stdc++.h>

using namespace std;

typedef char i1;
typedef unsigned char u1;
typedef short i2;
typedef unsigned short u2;
typedef int i4;
typedef unsigned int u4;
typedef long long i8;
typedef unsigned long long u8;
typedef float f4;
typedef double f8;

#define u2max ((u2)(~0U))
#define i2max ((i2)(u2max>>1))
#define i2min ((i2)(-i2max - 1))
#define u4max ((u4)(~0U))
#define i4max ((i4)(u4max>>1))
#define i4min (-i4max - 1)
#define u8max ((u8)(~0ULL))
#define i8max ((i8)(u8max>>1))
#define i8min (-i8max - 1)
#define f4min (numeric_limits<float>::min())
#define f4max (numeric_limits<float>::max())
#define f8min (numeric_limits<double>::min())
#define f8max (numeric_limits<double>::max())
#define f8inf (numeric_limits<f8>::infinity())
#define f4inf (numeric_limits<f4>::infinity())
#define inf f8inf

const f8 PI = 3.1415926;

template <typename T>
T gcd(T a, T b) { while (b){ T c = a % b; a = b; b = c; } return a; }
template <typename T>
T lcm(T a, T b){ assert(a/gcd(a, b) <= numeric_limits<T>::max()/b); return a * (b / gcd(a, b)); }
class out { public:
    template <typename T> out &operator()(const T &t){ cout << t << ' '; return *this; }
    template <typename T1, typename T2> out &operator()(const pair<T1, T2> &t){ cout << '(' << t.first << ',' << t.second << ')' << ' '; return *this; }};
template <typename iter> inline void print_(iter beg, iter end){ for_each(beg, end, out()); cout << endl; }
template<typename T> inline void print_(const T &t) { cout << t << endl; }
inline void print_(const char *fmt, ...) { va_list va; va_start(va, fmt); vprintf(fmt, va); va_end(va); }
//template<typename T, u4 M> inline void print_(const T (&t)[M] ) { for (u4 i = 0; i < M; ++i) { cout << t[i] << ' '; } cout << endl; }
//template<typename T, u4 M> inline void print_(const T (&t)[M], u4 c) { for (u4 i = 0; i < c; ++i) { cout << t[i] << ' '; } cout << endl; }
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N] ) { for (u4 i = 0; i < M; ++i) { for (u4 j = 0; j < N; ++j) { cout << t[i][j] << ' '; } cout << endl; }}
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N], u4 r, u4 c) { for (u4 i = 0; i < r; ++i) { for (u4 j = 0; j < c; ++j) { cout << t[i][j] << ' '; } cout << endl; } }
template<typename T> inline i4 BKDRHash(const T *str) { register i4 hash = 0; while (i4 ch = (i4)*str++) { hash = hash * 131 + ch; } return hash; }
inline u8 powxy(u8 x, i4 y = 2) { u8 r; for (r = 1; y > 0; --y) r *= x; return r; }
inline u8 factorial(u8 n) { u8 r; for (r = 1; n > 0; --n) r *= n; return r; }
inline u8 permutation(u8 n, u8 k) { u8 r = 1; while (k--) r *= n--; return r; }
inline u8 combination(u8 n, u8 k) { return permutation(n, k) / factorial(k); }

#define FILE
#define TRACE
#if defined DEBUG && defined TRACE
    #define print print_
#else
    #define print
#endif
i4 n, q, a[1000000], s2;
i8 s1, s3;
void shift(i8 x)
{
    i4 y = x % n;
    if (y >= 0)
        rotate(a, a+n-y, a+n);
    else
        rotate(a, a-y, a+n);
}
void swap(i4 x)
{
    if (x % 2)
    {
        for (i4 *p = a; p < a+n; p += 2)
            iter_swap(p, p+1);
    }
}
#ifndef NOMAIN
int main()
{
#if defined DEBUG && defined FILE
    freopen("in.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &q);
    for (i4 i = 0; i < n; ++i) a[i] = i + 1;
    for (i4 i = 0; i < q; ++i)
    {
        i4 c, x;
        scanf("%d", &c);
        if (c == 1)
        {
            scanf("%d", &x);
            if (x % 2)
            {
                shift(s1);
                s1 = 0;
                swap(s2);
                s2 = 0;
                s3 += x;
            }
            else
            {
                shift(s3);
                s3 = 0;
                s1 += x;
            }
        }
        else
        {
            shift(s3);
            s3 = 0;
            ++s2;
        }
    }
    shift(s1);
    swap(s2);
    shift(s3);
    for (i4 i = 0; i < n; ++i) printf("%d ", a[i]);
    return 0;
}
#endif


#include <bits/stdc++.h>

using namespace std;

typedef char i1;
typedef unsigned char u1;
typedef short i2;
typedef unsigned short u2;
typedef int i4;
typedef unsigned int u4;
typedef long long i8;
typedef unsigned long long u8;
typedef float f4;
typedef double f8;

#define u2max ((u2)(~0U))
#define i2max ((i2)(u2max>>1))
#define i2min ((i2)(-i2max - 1))
#define u4max ((u4)(~0U))
#define i4max ((i4)(u4max>>1))
#define i4min (-i4max - 1)
#define u8max ((u8)(~0ULL))
#define i8max ((i8)(u8max>>1))
#define i8min (-i8max - 1)
#define f4min (numeric_limits<float>::min())
#define f4max (numeric_limits<float>::max())
#define f8min (numeric_limits<double>::min())
#define f8max (numeric_limits<double>::max())
#define f8inf (numeric_limits<f8>::infinity())
#define f4inf (numeric_limits<f4>::infinity())
#define inf f8inf

const f8 PI = 3.1415926;

template <typename T>
T gcd(T a, T b) { while (b){ T c = a % b; a = b; b = c; } return a; }
template <typename T>
T lcm(T a, T b){ assert(a/gcd(a, b) <= numeric_limits<T>::max()/b); return a * (b / gcd(a, b)); }
class out { public:
    template <typename T> out &operator()(const T &t){ cout << t << ' '; return *this; }
    template <typename T1, typename T2> out &operator()(const pair<T1, T2> &t){ cout << '(' << t.first << ',' << t.second << ')' << ' '; return *this; }};
template <typename iter> inline void print_(iter beg, iter end){ for_each(beg, end, out()); cout << endl; }
template<typename T> inline void print_(const T &t) { cout << t << endl; }
inline void print_(const char *fmt, ...) { va_list va; va_start(va, fmt); vprintf(fmt, va); va_end(va); }
//template<typename T, u4 M> inline void print_(const T (&t)[M] ) { for (u4 i = 0; i < M; ++i) { cout << t[i] << ' '; } cout << endl; }
//template<typename T, u4 M> inline void print_(const T (&t)[M], u4 c) { for (u4 i = 0; i < c; ++i) { cout << t[i] << ' '; } cout << endl; }
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N] ) { for (u4 i = 0; i < M; ++i) { for (u4 j = 0; j < N; ++j) { cout << t[i][j] << ' '; } cout << endl; }}
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N], u4 r, u4 c) { for (u4 i = 0; i < r; ++i) { for (u4 j = 0; j < c; ++j) { cout << t[i][j] << ' '; } cout << endl; } }
template<typename T> inline i4 BKDRHash(const T *str) { register i4 hash = 0; while (i4 ch = (i4)*str++) { hash = hash * 131 + ch; } return hash; }
inline u8 powxy(u8 x, i4 y = 2) { u8 r; for (r = 1; y > 0; --y) r *= x; return r; }
inline u8 factorial(u8 n) { u8 r; for (r = 1; n > 0; --n) r *= n; return r; }
inline u8 permutation(u8 n, u8 k) { u8 r = 1; while (k--) r *= n--; return r; }
inline u8 combination(u8 n, u8 k) { return permutation(n, k) / factorial(k); }

#define FILE
#define TRACE
#if defined DEBUG && defined TRACE
    #define print print_
#else
    #define print
#endif
i4 n, q, a[1000000], b, d, s1, s2;
inline void shift(i4 y)
{
    b = (b-y) % n;
    if (b < 0) b += n;
}
inline void swap()
{
    if (d % 2)
    {
        if (b % 2) ++d;
        else --d;
    }
    else
    {
        if (b % 2) --d;
        else ++d;
    }
}
#ifndef NOMAIN
int main()
{
#if defined DEBUG && defined FILE
    freopen("in.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &q);
    for (i4 i = 0; i < q; ++i)
    {
        i4 c, x;
        scanf("%d", &c);
        if (c == 1)
        {
            if (s2)
            {
                if (s1 % 2)
                {
                    shift(s1);
                    s1 = 0;
                }
                swap();
                s2 = 0;
            }
            scanf("%d", &x);
            s1 = (s1+x) % n;
        }
        else s2 = 1 ^ s2;
        print(a, a+n);
    }
    shift(s1);
    if (s2) swap();
    for (i4 i = 0; i < n; i += 2)
    {
        i4 t = (i+d) % n;
        if (t < 0) t += n;
        a[t] = i+1;
    }
    for (i4 i = 1; i < n; i += 2)
    {
        i4 t = (i-d) % n;
        if (t < 0) t += n;
        a[t] = i+1;
    }
    for (i4 i = b; i < b+n; ++i)
        printf("%d ", a[i%n]);
    return 0;
}
#endif


#include <bits/stdc++.h>

using namespace std;

typedef char i1;
typedef unsigned char u1;
typedef short i2;
typedef unsigned short u2;
typedef int i4;
typedef unsigned int u4;
typedef long long i8;
typedef unsigned long long u8;
typedef float f4;
typedef double f8;

#define u2max ((u2)(~0U))
#define i2max ((i2)(u2max>>1))
#define i2min ((i2)(-i2max - 1))
#define u4max ((u4)(~0U))
#define i4max ((i4)(u4max>>1))
#define i4min (-i4max - 1)
#define u8max ((u8)(~0ULL))
#define i8max ((i8)(u8max>>1))
#define i8min (-i8max - 1)
#define f4min (numeric_limits<float>::min())
#define f4max (numeric_limits<float>::max())
#define f8min (numeric_limits<double>::min())
#define f8max (numeric_limits<double>::max())
#define f8inf (numeric_limits<f8>::infinity())
#define f4inf (numeric_limits<f4>::infinity())
#define inf f8inf

const f8 PI = 3.1415926;

template <typename T>
T gcd(T a, T b) { while (b){ T c = a % b; a = b; b = c; } return a; }
template <typename T>
T lcm(T a, T b){ assert(a/gcd(a, b) <= numeric_limits<T>::max()/b); return a * (b / gcd(a, b)); }
class out { public:
    template <typename T> out &operator()(const T &t){ cout << t << ' '; return *this; }
    template <typename T1, typename T2> out &operator()(const pair<T1, T2> &t){ cout << '(' << t.first << ',' << t.second << ')' << ' '; return *this; }};
template <typename iter> inline void print_(iter beg, iter end){ for_each(beg, end, out()); cout << endl; }
template<typename T> inline void print_(const T &t) { cout << t << endl; }
inline void print_(const char *fmt, ...) { va_list va; va_start(va, fmt); vprintf(fmt, va); va_end(va); }
//template<typename T, u4 M> inline void print_(const T (&t)[M] ) { for (u4 i = 0; i < M; ++i) { cout << t[i] << ' '; } cout << endl; }
//template<typename T, u4 M> inline void print_(const T (&t)[M], u4 c) { for (u4 i = 0; i < c; ++i) { cout << t[i] << ' '; } cout << endl; }
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N] ) { for (u4 i = 0; i < M; ++i) { for (u4 j = 0; j < N; ++j) { cout << t[i][j] << ' '; } cout << endl; }}
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N], u4 r, u4 c) { for (u4 i = 0; i < r; ++i) { for (u4 j = 0; j < c; ++j) { cout << t[i][j] << ' '; } cout << endl; } }
template<typename T> inline i4 BKDRHash(const T *str) { register i4 hash = 0; while (i4 ch = (i4)*str++) { hash = hash * 131 + ch; } return hash; }
inline u8 powxy(u8 x, i4 y = 2) { u8 r; for (r = 1; y > 0; --y) r *= x; return r; }
inline u8 factorial(u8 n) { u8 r; for (r = 1; n > 0; --n) r *= n; return r; }
inline u8 permutation(u8 n, u8 k) { u8 r = 1; while (k--) r *= n--; return r; }
inline u8 combination(u8 n, u8 k) { return permutation(n, k) / factorial(k); }

#define FILE
#define TRACE
#if defined DEBUG && defined TRACE
    #define print print_
#else
    #define print
#endif
i4 n, q, a[1000000], b;
i8 s1;
i4 s2;
void shift(i8 y)
{
    b = (b-y) % n;
    if (b < 0) b = n + b;
}
void swap()
{
    for (i4 i = b; i < b+n; i+=2)
        swap(a[i%n], a[(i+1)%n]);
}
#ifndef NOMAIN
int main()
{
#if defined DEBUG && defined FILE
    freopen("in.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &q);
    for (i4 i = 0; i < n; ++i) a[i] = i + 1;
    for (i4 i = 0; i < q; ++i)
    {
        i4 c, x;
        scanf("%d", &c);
        if (c == 1)
        {
            if (s2)
            {
                if (s1 % 2)
                {
                    shift(s1);
                    s1 = 0;
                    swap();
                    s2 = 0;
                }
                else
                {
                    swap();
                    s2 = 0;
                }
            }
            scanf("%d", &x);
            s1 += x;
        }
        else
        {
            s2 = 1 ^ s2;
        }
        print(a, a+n);
    }
    shift(s1);
    if (s2) swap();
    for (i4 i = b; i < b+n; ++i)
        printf("%d ", a[i%n]);
    return 0;
}
#endif


#include <bits/stdc++.h>

using namespace std;

typedef char i1;
typedef unsigned char u1;
typedef short i2;
typedef unsigned short u2;
typedef int i4;
typedef unsigned int u4;
typedef long long i8;
typedef unsigned long long u8;
typedef float f4;
typedef double f8;

#define u2max ((u2)(~0U))
#define i2max ((i2)(u2max>>1))
#define i2min ((i2)(-i2max - 1))
#define u4max ((u4)(~0U))
#define i4max ((i4)(u4max>>1))
#define i4min (-i4max - 1)
#define u8max ((u8)(~0ULL))
#define i8max ((i8)(u8max>>1))
#define i8min (-i8max - 1)
#define f4min (numeric_limits<float>::min())
#define f4max (numeric_limits<float>::max())
#define f8min (numeric_limits<double>::min())
#define f8max (numeric_limits<double>::max())
#define f8inf (numeric_limits<f8>::infinity())
#define f4inf (numeric_limits<f4>::infinity())
#define inf f8inf

const f8 PI = 3.1415926;

template <typename T>
T gcd(T a, T b) { while (b){ T c = a % b; a = b; b = c; } return a; }
template <typename T>
T lcm(T a, T b){ assert(a/gcd(a, b) <= numeric_limits<T>::max()/b); return a * (b / gcd(a, b)); }
class out { public:
    template <typename T> out &operator()(const T &t){ cout << t << ' '; return *this; }
    template <typename T1, typename T2> out &operator()(const pair<T1, T2> &t){ cout << '(' << t.first << ',' << t.second << ')' << ' '; return *this; }};
template <typename iter> inline void print_(iter beg, iter end){ for_each(beg, end, out()); cout << endl; }
template<typename T> inline void print_(const T &t) { cout << t << endl; }
inline void print_(const char *fmt, ...) { va_list va; va_start(va, fmt); vprintf(fmt, va); va_end(va); }
//template<typename T, u4 M> inline void print_(const T (&t)[M] ) { for (u4 i = 0; i < M; ++i) { cout << t[i] << ' '; } cout << endl; }
//template<typename T, u4 M> inline void print_(const T (&t)[M], u4 c) { for (u4 i = 0; i < c; ++i) { cout << t[i] << ' '; } cout << endl; }
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N] ) { for (u4 i = 0; i < M; ++i) { for (u4 j = 0; j < N; ++j) { cout << t[i][j] << ' '; } cout << endl; }}
template<typename T, u4 M, u4 N> inline void print_(const T (&t)[M][N], u4 r, u4 c) { for (u4 i = 0; i < r; ++i) { for (u4 j = 0; j < c; ++j) { cout << t[i][j] << ' '; } cout << endl; } }
template<typename T> inline i4 BKDRHash(const T *str) { register i4 hash = 0; while (i4 ch = (i4)*str++) { hash = hash * 131 + ch; } return hash; }
inline u8 powxy(u8 x, i4 y = 2) { u8 r; for (r = 1; y > 0; --y) r *= x; return r; }
inline u8 factorial(u8 n) { u8 r; for (r = 1; n > 0; --n) r *= n; return r; }
inline u8 permutation(u8 n, u8 k) { u8 r = 1; while (k--) r *= n--; return r; }
inline u8 combination(u8 n, u8 k) { return permutation(n, k) / factorial(k); }

#define FILE
#define TRACE
#if defined DEBUG && defined TRACE
    #define print print_
#else
    #define print
#endif
i4 n, q;
list<i4> a;
i8 s1;
i4 s2;
void shift(i8 x)
{
    print("shift\n");
    print(a.begin(), a.end());
    i4 y = x % n;
    list<i4>::iterator iter = a.begin();
    if (y >= 0)
    {
        advance(iter, n-y);
        a.splice(a.begin(), a, iter, a.end());
    }
    else
    {
        advance(iter, -y); // y<0
        a.splice(a.begin(), a, iter, a.end());
    }
    print(a.begin(), a.end());
}
void swap()
{
    print("swap\n");
    print(a.begin(), a.end());
    for (list<i4>::iterator iter = a.begin(); iter != a.end(); advance(iter, 2))
    {
        list<i4>::iterator iter2 = iter;
        ++iter2;
        iter_swap(iter, iter2);
    }
    print(a.begin(), a.end());
}
#ifndef NOMAIN
int main()
{
#if defined DEBUG && defined FILE
    freopen("in.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &q);
    for (i4 i = 0; i < n; ++i) a.push_back(i + 1);
    for (i4 i = 0; i < q; ++i)
    {
        i4 c, x;
        scanf("%d", &c);
        if (c == 1)
        {
            if (s2)
            {
                if (s1 % 2)
                {
                    shift(s1);
                    s1 = 0;
                    swap();
                    s2 = 0;
                }
                else
                {
                    swap();
                    s2 = 0;
                }
            }
            scanf("%d", &x);
            s1 += x;
        }
        else
        {
            s2 = 1 ^ s2;
        }
    }
    shift(s1);
    if (s2) swap();
    for (list<i4>::iterator iter = a.begin(); iter != a.end(); ++iter)
        printf("%d ", *iter);
    return 0;
}
#endif


#include <stdio.h>
using namespace std;
const int N=1e6+10;
int foo[N];
int main() {
    int n,q;
    scanf("%d%d",&n,&q);
    int ffx,ddo;
    int s1=1,s2=2;
    while(q--){
        scanf("%d",&ffx);
        if(ffx==1){
            scanf("%d",&ddo);
            s1=((s1+ddo+n)%n==0?n:(s1+ddo+n)%n);
            s2=((s2+ddo+n)%n==0?n:(s2+ddo+n)%n);
        }
        else{
            if(s1%2) s1++;
            else s1--;
            if(s2%2) s2++;
            else s2--;
        }
    }
    for(int i=1;i<=n;i++){
        if(i%2){
            int u=s1%n;
            if(u==0) u=n;
            foo[u]=i;
            s1+=2;
        }
        else{
            int u=s2%n;
            if(u==0) u=n;
            foo[u]=i;
            s2+=2;
        }
    }
    for(int i=1;i<=n;i++) printf("%d ",foo[i]);puts("");
    return 0;
}


#include <stdio.h>
using namespace std;
const int N=1e6+10;
int foo[N];
int too[N];
int main() {
    int n,qq;
    scanf("%d%d",&n,&qq);
    int flag=0;
    int ffx,ddo;
    int s1=0,s2=0;
    int q=0;
    for(int i=1; i<=n; i++) too[i]=i;
    while(qq--) {
        scanf("%d",&ffx);
        if(ffx==1) {
            if(flag==0) {
                q=1;
                flag=1;
            }
            scanf("%d",&ddo);
            s1+=ddo;
        } else {
            if(flag==0) {
                q=2;
                flag=1;
            }
            s2++;
        }
    }
    s1=s1%n;
    if(q==2) {
        if(s2%2) {
            for(int i=1; i<=n; i+=2) {
                int t=too[i];
                too[i]=too[i+1];
                too[i+1]=t;
            }
            for(int i=1;i<=n;i++) foo[i]=too[i];
        }
        for(int i=1; i<=n; i++) {
            int y=(i+s1+n)%n;
            if(y==0) y=n;
            too[y]=foo[i];
        }
        for(int i=1;i<=n;i++){
            foo[i]=too[i];
        }
    }
    else{
        for(int i=1; i<=n; i++) {
            int y=(i+s1+n)%n;
            if(y==0) y=n;
            too[y]=i;
        }
        if(s2%2) {
            for(int i=1; i<=n; i+=2) {
                int t=too[i];
                too[i]=too[i+1];
                too[i+1]=t;
            }
            for(int i=1;i<=n;i++) foo[i]=too[i];
        }
    }
    for(int i=1;i<=n;i++) printf("%d ",foo[i]);puts("");
    return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
const int N=1e6+10;
int foo[N];
int too[N];
int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    int ffx,ddo;
    int s1=0,s2=0;
    while(q--){
        scanf("%d",&ffx);
        if(ffx==1){
            scanf("%d",&ddo);
            s1+=ddo;
        }
        else{
            s2++;
        }
    }
    if(s1<0){
        s1=s1%n;
        s1+=n;
    }
    else{
        s1=s1%n;
    }
    //那么1现在就在1+s1这个位置
    for(int i=1;i<=n;i++){
        int y=(s1+i)%n;
        if(y==0) y=n;
        foo[y]=i;
        too[i]=y;
    }
    if(s2%2){
        for(int i=1;i<=n;i+=2){
            swap(foo[too[i]],foo[too[i+1]]);
        }
    }
    for(int i=1;i<=n;i++) printf("%d ",foo[i]);
    puts("");
    return 0;
}


#include <stdio.h>
using namespace std;
const int N=1e6+10;
int foo[N];
int too[N];
int main() {
    int n,qq;
    scanf("%d%d",&n,&qq);
    int flag=0;
    int ffx,ddo;
    int s1=0,s2=0;
    int q=0;
    for(int i=1; i<=n; i++) too[i]=i;
    while(qq--) {
        scanf("%d",&ffx);
        if(ffx==1) {
            if(flag==0) {
                q=1;
                flag=1;
            }
            scanf("%d",&ddo);
            s1+=ddo;
        } else {
            if(flag==0) {
                q=2;
                flag=1;
            }
            s2++;
        }
    }
    s1=s1%n;
    if(q==2) {
        if(s2%2) {
            for(int i=1; i<=n; i+=2) {
                int t=too[i];
                too[i]=too[i+1];
                too[i+1]=t;
            }
            for(int i=1;i<=n;i++) foo[i]=too[i];
        }
        for(int i=1; i<=n; i++) {
            int y=(i+s1+n)%n;
            if(y==0) y=n;
            too[y]=foo[i];
        }
        for(int i=1;i<=n;i++){
            foo[i]=too[i];
        }
    }
    else{
        for(int i=1; i<=n; i++) {
            int y=(i+s1+n)%n;
            if(y==0) y=n;
            too[y]=i;
        }
        if(s2%2) {
            for(int i=1; i<=n; i+=2) {
                int t=too[i];
                too[i]=too[i+1];
                too[i+1]=t;
            }
            for(int i=1;i<=n;i++) foo[i]=too[i];
        }
        for(int i=1;i<=n;i++) foo[i]=too[i];
    }
    for(int i=1;i<=n;i++) printf("%d ",foo[i]);puts("");
    return 0;
}


#include <stdio.h>
using namespace std;
const int N=1e6+10;
int foo[N];
int main() {
    int n,q;
    scanf("%d%d",&n,&q);
    int ffx,ddo;
    int s1=1,s2=2;
    while(q--){
        scanf("%d",&ffx);
        if(ffx==1){
            scanf("%d",&ddo);
            s1=(s1+ddo+n)%n;
            s2=(s2+ddo+n)%n;
        }
        else{
            if(s1%2) s1++;
            else s1--;
            if(s2%2) s2++;
            else s2--;
        }
    }
    for(int i=1;i<=n;i++){
        if(i%2){
            int u=s1%n;
            if(u==0) u=n;
            foo[u]=i;
            s1+=2;
        }
        else{
            int u=s2%n;
            if(u==0) u=n;
            foo[u]=i;
            s2+=2;
        }
    }
    for(int i=1;i<=n;i++) printf("%d ",foo[i]);puts("");
    return 0;
}


/*#include <iostream>
#include <stdio.h>
using namespace std;
int extend_gcd(int a,int b,int &x,int &y){
    if(b==0){
        x=1,y=0;
        return a;
    }
    int ans=extend_gcd(b,a%b,x,y);
    int t=x;
    x=y;
    y=t-a/b*y;
    return ans;
}
int main(){
    int m,n;
    int x,y;
    scanf("%d%d",&m,&n);
    extend_gcd(m,n,x,y);
    printf("%d\n",(x%n+n)%n);
    return 0;
}
*/
/*
#include <stdio.h>
#define LL long long
using namespace std;
LL extend_gcd(LL a,LL b,LL &x,LL &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    LL ans=extend_gcd(b,a%b,x,y);
    LL t=x;
    x=y;
    y=t-a/b*y;
    return ans;
}
LL gcd(LL a,LL b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int main(){
    LL x,y,m,n,L;
    scanf("%I64d%I64d%I64d%I64d%I64d",&x,&y,&m,&n,&L);
    LL a=n-m;
    LL b=L;
    LL c=x-y;
    if(a<0){
        a=-a;
        c=-c;
    }
    LL gc=gcd(a,b);
    if(c%gc!=0){
        puts("Impossible");
    }
    else{
        LL t,k;
        extend_gcd(a,b,t,k);
        c/=gc;
        L/=gc;
        t*=c;
        printf("%I64d\n",(t%L+L)%L);
    }
    return 0;
}
*/
/*
#include <iostream>
using namespace std;

long long t, p, c;

void extend_euild(int a, int b)
{
    if(b == 0)
    {
        t = 1;
        p = 0;
        c = a;
    }
    else
    {
        extend_euild(b, a%b);
        int temp = t;
        t = p;
        p = temp - a/b*p;
    }
}

int main()
{
    int i, j, ok = 0, d, a, b;
    long long x, y, m, n, l;

    cin >> x >> y >> m >> n >> l;

    if(n == m)
        ok = 1;
    else{
        a = n-m;
        d = x-y;
        b = l;
        extend_euild(a, b);
        if(d % c !=0)
            ok = 1;
    }
    if(ok)
        cout << "Impossible" << endl;
    else
    {
        b = b / c;
        d = d / c;
        long long v = d * t;
        cout << (v%b+b)%b << endl;
    }

    return 0;
}
*/
#include <stdio.h>
using namespace std;
const int N=1e6+10;
int foo[N];
int too[N];
int main() {
    int n,qq;
    scanf("%d%d",&n,&qq);
    int flag=0;
    int ffx,ddo;
    int s1=0,s2=0;
    int q=0;
    for(int i=1; i<=n; i++) too[i]=i;
    while(qq--) {
        scanf("%d",&ffx);
        if(ffx==1) {
            if(flag==0) {
                q=1;
                flag=1;
            }
            scanf("%d",&ddo);
            s1+=ddo;
        } else {
            if(flag==0) {
                q=2;
                flag=1;
            }
            s2++;
        }
    }
    if(q==2) {
        if(s2%2) {
            for(int i=1; i<=n; i+=2) {
                int t=too[i];
                too[i]=too[i+1];
                too[i+1]=t;
            }
        }
        for(int i=1; i<=n; i++) {
            foo[i]=too[i];
        }
        for(int i=1; i<=n; i++) {
            int y=(i+s1)%n;
            if(y==0) y=n;
            too[y]=foo[i];
        }
        for(int i=1; i<=n; i++) {
            foo[i]=too[i];
        }
    } else {
        for(int i=1; i<=n; i++) {
            foo[i]=too[i];
        }
        for(int i=1; i<=n; i++) {
            int y=(i+s1)%n;
            if(y==0) y=n;
            too[y]=foo[i];
        }
        for(int i=1; i<=n; i++) {
            foo[i]=too[i];
        }
        if(s2%2) {
            for(int i=1; i<=n; i+=2) {
                int t=too[i];
                too[i]=too[i+1];
                too[i+1]=t;
            }
        }
        for(int i=1; i<=n; i++) {
            foo[i]=too[i];
        }
    }
    for(int i=1; i<=n; i++) printf("%d ",foo[i]);
    puts("");
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <string.h>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>

using namespace std;

typedef long long ll;

const int N = 1000010;

int n , q  , t , x;

ll mv;

int odd;
int even;

int pos[N];

int handle(ll pos) {
	while (pos > n) {
		pos -= n;
	}
	while (pos < 1)
		pos += n;
	return pos;
}
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d%d", &n, &q);
	for (int i = 0; i < q; ++i) {
		scanf("%d", &t);
		if (t == 1) {
			scanf("%d", &x);
			if(x < 0){
				mv += (ll) (n + x);
			}else{
				mv += (ll)x;
			}
		} else {
			if (mv % 2 == 0) {
				odd++;
				even--;
			} else {
				odd--;
				even++;
			}
		}
	}
	for (int i = 1 ; i <= n ; i++) {
		if (i % 2) {
			pos[handle(i + mv + odd)] = i;
		} else {
			pos[handle(i + mv + even)] = i;
		}
	}
	for (int i = 1 ; i <= n; ++i) {
		if (i > 1)
			printf(" ");
		printf("%d", pos[i]);
	}
	puts("");
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <string.h>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>

using namespace std;

typedef long long ll;

const int N = 1000010;

int n , q  , t , x;

ll mv;

int odd;
int even;

int pos[N];

int handle(ll pos) {
	while (pos > n) {
		pos -= n;
	}
	while (pos < 1)
		pos += n;
	return pos;
}
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d%d", &n, &q);
	for (int i = 0; i < q; ++i) {
		scanf("%d", &t);
		if (t == 1) {
			scanf("%d", &x);
			if(x < 0){
				mv += (ll) (n - x);
			}else{
				mv += (ll)x;
			}
		} else {
			if (mv % 2 == 0) {
				odd++;
				even--;
			} else {
				odd--;
				even++;
			}
		}
	}
	for (int i = 1 ; i <= n ; i++) {
		if (i % 2) {
			pos[handle(i + mv + odd)] = i;
		} else {
			pos[handle(i + mv + even)] = i;
		}
	}
	for (int i = 1 ; i <= n; ++i) {
		if (i > 1)
			printf(" ");
		printf("%d", pos[i]);
	}
	puts("");
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <string.h>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>

using namespace std;

typedef long long ll;

const int N = 1000010;

int n , q  , t , x;

ll mv;

int odd;
int even;

int pos[N];

int handle(ll pos) {
	while (pos > n) {
		pos -= n;
	}
	while (pos < 1)
		pos += n;
	return pos;
}
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d%d", &n, &q);
	for (int i = 0; i < q; ++i) {
		scanf("%d", &t);
		if (t == 1) {
			scanf("%d", &x);
			mv += (ll)x;
		} else {
			if (mv % 2 == 0) {
				odd++;
				even--;
			} else {
				odd--;
				even++;
			}
		}
	}
	for (int i = 1 ; i <= n ; i++) {
		if (i % 2) {
			pos[handle(i + mv + odd)] = i;
		} else {
			pos[handle(i + mv + even)] = i;
		}
	}
	for (int i = 1 ; i <= n; ++i) {
		if (i > 1)
			printf(" ");
		printf("%d", pos[i]);
	}
	puts("");
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <string.h>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>

using namespace std;

typedef long long ll;

const int N = 1000010;

int n , q  , t , x;

ll mv;

int odd;
int even;

int pos[N];

bool oddturn = true;

int handle(ll pos) {
	while (pos > n) {
		pos -= n;
	}
	while (pos < 1)
		pos += n;
	return pos;
}
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d%d", &n, &q);
	for (int i = 0; i < q; ++i) {
		scanf("%d", &t);
		if (t == 1) {
			scanf("%d", &x);
			if(x < 0){
				mv += (ll) (n + x);
			}else{
				mv += (ll)x;
			}
		} else {
			if (mv % 2 == 0) {
				if(oddturn){
					odd++;
					even--;
				}else{
					odd--;
					even++;
				}
			} else {
				if(oddturn){
					odd--;
					even++;
				}else{
					odd++;
					even--;
				}
			}
			oddturn = !oddturn;
		}
	}
	while (mv > n) {
		mv -= n;
	}
	for (int i = 1 ; i <= n ; i++) {
		if (i % 2) {
			pos[handle(i + mv + odd)] = i;
		} else {
			pos[handle(i + mv + even)] = i;
		}
	}
	for (int i = 1 ; i <= n; ++i) {
		if (i > 1)
			printf(" ");
		printf("%d", pos[i]);
	}
	puts("");
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <string.h>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>

using namespace std;

typedef long long ll;

const int N = 1000010;

int n , q  , t , x;

ll mv;

int odd;
int even;

int pos[N];

bool oddturn = true;

int handle(ll pos) {
	while (pos > n) {
		pos -= n;
	}
	while (pos < 1)
		pos += n;
	return pos;
}
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d%d", &n, &q);
	for (int i = 0; i < q; ++i) {
		scanf("%d", &t);
		if (t == 1) {
			scanf("%d", &x);
			if(x < 0){
				mv += (ll) (n + x);
			}else{
				mv += (ll)x;
			}
		} else {
			if (mv % 2 == 0) {
				if(oddturn){
					odd++;
					even--;
				}else{
					odd--;
					even++;
				}
			} else {
				if(oddturn){
					odd--;
					even++;
				}else{
					odd++;
					even--;
				}
			}
			oddturn = !oddturn;
		}
	}
	for (int i = 1 ; i <= n ; i++) {
		if (i % 2) {
			pos[handle(i + mv + odd)] = i;
		} else {
			pos[handle(i + mv + even)] = i;
		}
	}
	for (int i = 1 ; i <= n; ++i) {
		if (i > 1)
			printf(" ");
		printf("%d", pos[i]);
	}
	puts("");
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <string.h>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>

using namespace std;

typedef long long ll;

const int N = 1000010;

int n , q  , t , x;

ll move;

int odd;
int even;

int pos[N];

int handle(ll pos){
	while(pos > n){
		pos -= n;
	}
	while(pos < 1)
		pos += n;
	return pos;
}
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d%d", &n, &q);
	for (int i = 0; i < q; ++i) {
		scanf("%d", &t);
		if (t == 1) {
			scanf("%d", &x);
			move += (ll)x;
		} else {
			if (move % 2 == 0) {
				odd++;
				even--;
			} else {
				odd--;
				even++;
			}
		}
	}
	for (int i = 1 ; i <= n ; i++) {
		if (i % 2) {
			pos[handle(i + move + odd)] = i;
		}else{
			pos[handle(i + move + even)] = i;
		}
	}
	for (int i = 1 ; i <= n; ++i){
		if(i > 1)
			printf(" ");
		printf("%d", pos[i]);
	}
	puts("");
	return 0;
}


#include <bits/stdc++.h>
#define N 1000100

using namespace std;
int n,q;
int t,c;
int tab[N];
typedef pair<int,int> ii;
vector<ii> queries;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>q;
	register long long a=0;
	register long long b=1;
	for(register int i=0;i<q;++i)
	{
		cin>>t;
		if(t==2) queries.push_back(ii(t,0));
		else
		{
			cin>>c;
			queries.push_back(ii(t,c));
		}
	}
	for(register int i=0;i<q;++i)
	{
		t = queries[i].first;
		c = queries[i].second;
		if(t==2)
		{
			if(a%2==0) a++,b--;
			else	b++,a--;
		}
		else
		{
			a+=c;
			b+=c;
		}
	}
	a%=n;
	b%=n;
	if(a%2==0)
	{
		register int p1 = n-a;
		register int p2 = n-b+1;
		for(register int i=0;i<n;++i)
		{
			if(i%2==0)
			{
				cout<<(i+p1)%n+1<<" ";
			}
			else
			{
				cout<<(i+p2)%n+1<<" ";
			}
		}
	}
	else
	{
		register int p1 = n-a;
		register int p2 = n-b+1;
		for(register int i=0;i<n;++i)
		{
			if(i%2==1)
				cout<<(i+p1)%n+1<<" ";
			else
				cout<<(i+p2)%n+1<<" ";
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
int n,q;
int t,c;
typedef pair<int,int> ii;
vector<ii> queries;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>q;
	register int a=0;
	register int b=1;
	for(register int i=0;i<q;++i)
	{
		cin>>t;
		if(t==2)
		{
			if(a%2==0) a++,b--;
			else	b++,a--;
		}
		else
		{
			cin>>c;
			a+=c;
			b+=c;
			a%=n;
			b%=n;
		}
	}
	a=(a+n)%n;
	b=(b+n)%n;
	if(a%2==0)
	{
		register int p1 = n-a;
		register int p2 = n-b+1;
		for(register int i=0;i<n;++i)
		{
			if(i%2==0)
			{
				cout<<(i+p1)%n+1<<" ";
			}
			else
			{
				cout<<(i+p2)%n+1<<" ";
			}
		}
	}
	else
	{
		register int p1 = n-a;
		register int p2 = n-b+1;
		for(register int i=0;i<n;++i)
		{
			if(i%2==1)
				cout<<(i+p1)%n+1<<" ";
			else
				cout<<(i+p2)%n+1<<" ";
		}
	}
	return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <queue>
#include <utility>
#include <fstream>
using namespace std;
struct event {
    int x,type,y,righty;
};
struct P {
    int right,dsu,number;
};
int xbegin[1000000],compcount,fen[1001000],xend[1000000],realx[1000000],realy[1000000],ybegin[1000000],yend[1000000],parent[1000000];
event events[1000000];
long long ans[1000000],best;
pair <int,int> xx[1000000],yy[1000000];
map <int, P> lefts;
set <int> s;
int v,n;
void event_vertical(int x, int yl, int yr) {
    v++;
    events[v].x=x;
    events[v].type=2;
    events[v].y=yl;
    events[v].righty=yr;
}
void event_horizantal_begin(int x, int y, int xx) {
    v++;
    events[v].x=x;
    events[v].type=1;
    events[v].y=y;
    events[v].righty=xx;
}
void event_horizantal_end(int x, int y) {
    v++;
    events[v].x=x;
    events[v].type=3;
    events[v].y=y;
    events[v].righty=0;
}
bool CMP (const event& i, const event& j) {
    return (i.x<j.x || (i.x==j.x && i.type<j.type));
}
void compressX() {
    for (int i=1;i<=n;i++) xx[i]=make_pair(xbegin[i],i);
    for (int i=1;i<=n;i++) xx[i+n]=make_pair(xend[i],i+n);
    sort(xx+1,xx+2*n+1);
    int v=0;
    xx[0]=make_pair(xx[1].first-1,0);
    for (int i=1;i<=2*n;i++) {
        if (xx[i].first!=xx[i-1].first) v++;
        realx[v]=xx[i].first;
        int t=xx[i].second;
        if (t>n) xend[t-n]=v;
        else xbegin[t]=v;
    }
}
void compressY() {
    for (int i=1;i<=n;i++) yy[i]=make_pair(ybegin[i],i);
    for (int i=1;i<=n;i++) yy[i+n]=make_pair(yend[i],i+n);
    sort(yy+1,yy+2*n+1);
    int v=0;
    yy[0]=make_pair(yy[1].first-1,0);
    for (int i=1;i<=2*n;i++) {
        if (yy[i].first!=yy[i-1].first) v++;
        realy[v]=yy[i].first;
        int t=yy[i].second;
        if (t>n) yend[t-n]=v;
        else ybegin[t]=v;
    }
}
void init() {
    cin >> n;
    for (int i=1;i<=n;i++) cin >> xbegin[i] >> ybegin[i] >> xend[i] >> yend[i];
    compressX();
    compressY();
}
void make_events() {
    v=0;
    for (int i=1;i<=n;i++) {
        if (xbegin[i]==xend[i]) event_vertical(xbegin[i],ybegin[i],yend[i]);
        else {
            event_horizantal_begin(xbegin[i],ybegin[i],xend[i]);
            event_horizantal_end(xend[i],ybegin[i]);
        }
    }
    sort(events+1,events+v+1, CMP);
}
int findsum(int x) {
    int s=0;
    while (x>=1) {
        s+=fen[x];
        x=(x & (x-1));
    }
    return s;
}
void md(int x, int y) {
    while (x<=1000000) {
        fen[x]+=y;
        x=(x | (x-1))+1;
    }
}
int findset(int x) {
    if (parent[x]==0) return x;
    parent[x]=findset(parent[x]);
    return parent[x];
}
void divide(int y, int l) {
    set<int>::iterator it2=s.upper_bound(y);
    it2--;
    P cnt=lefts[l];
    if (y>l) {
        int r=*it2;
        int nsize=findsum(r)-findsum(l-1);
        lefts[l].right=r;
        lefts[l].number=nsize;
    } else lefts.erase(l);
    if (y<cnt.right) {
        it2++;
        int nl=*it2;
        int nsize=findsum(cnt.right)-findsum(nl-1);
        lefts[nl].right=cnt.right;
        lefts[nl].dsu=findset(cnt.dsu);
        lefts[nl].number=nsize;
    }
}
int main() {
   // freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    init();
    make_events();
    compcount=0;
    best=0;
    s.insert(0);
    s.insert(200000000);
    lefts[200000000].right=200000000;
    lefts[0].right=0;
    for (int i=1;i<=v;i++) {
        if (events[i].type==1) {
            int y=events[i].y;
            compcount++;
            ans[compcount]=realx[events[i].righty]-realx[events[i].x];
            map<int,P>::iterator it1=lefts.upper_bound(y);
            it1--;
            int l=it1->first;
            if (l<=y && y<=lefts[l].right) divide(y,l);
            s.insert(y);
            lefts[y].right=y;
            lefts[y].dsu=compcount;
            lefts[y].number=1;
            md(y,1);
        }
        if (events[i].type==3) {
            int y=events[i].y;
            s.erase(y);
            map<int, P>::iterator it=lefts.upper_bound(y);
            it--;
            md(y,-1);
            int l=it->first;
            if (lefts[l].right==l) lefts.erase(l);
            else divide(y,l);
        }
        if (events[i].type==2) {
            int yl=events[i].y;
            int yr=events[i].righty;
            if (realy[yr]-realy[yl]>best) best=realy[yr]-realy[yl];
            if (findsum(yr)-findsum(yl-1)==0) continue;
            int nDSU=0;
            int nl=0;
            int nr=0;
            int dif=1;
            map<int, P>::iterator it=lefts.upper_bound(yl);
            it--;
            int l=it->first;
            P cnt=lefts[l];
            if (cnt.right>=yl && l<=yl) {
                nl=l;
                nr=cnt.right;
                nDSU=findset(cnt.dsu);
                lefts.erase(l);
            }
            while (true) {
                map<int, P>::iterator it1=lefts.lower_bound(yl);
                int l=it1->first;
                if (lefts[l].right>yr) break;
                if (nl==0) nl=l;
                P cnt=lefts[l];
                nr=cnt.right;
                if (nDSU==0) nDSU=findset(cnt.dsu);
                else
                if (nDSU!=findset(cnt.dsu)) {
                    ans[nDSU]+=ans[findset(cnt.dsu)];
                    parent[findset(cnt.dsu)]=nDSU;
                    dif++;
                }
                lefts.erase(l);
            }
            it=lefts.upper_bound(yr);
            it--;
            l=it->first;
            cnt=lefts[l];
            if (cnt.right>=yr && l<=yr) {
                if (nl==0) nl=l;
                nr=cnt.right;
                if (nDSU==0) nDSU=findset(cnt.dsu);
                else
                if (nDSU!=findset(cnt.dsu)) {
                    ans[nDSU]+=ans[findset(cnt.dsu)];
                    parent[findset(cnt.dsu)]=nDSU;
                    dif++;
                }
                lefts.erase(l);
            }
            if (nDSU!=0) {
                lefts[nl].right=nr;
                lefts[nl].dsu=nDSU;
                lefts[nl].number=findsum(nr)-findsum(nl-1);
                ans[nDSU]+=realy[yr]-realy[yl]-findsum(yr)+findsum(yl-1)+dif;
            }
        }
    }
    for (int i=1;i<=compcount;i++)
        if (ans[i]>best) best=ans[i];
    cout << best << endl;
    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <queue>
#include <utility>
#include <fstream>
using namespace std;
struct event {
    int x,type,y,righty;
};
struct P {
    int right,dsu,number;
};
int xbegin[1000000],compcount,fen[1000000],xend[1000000],ybegin[1000000],yend[1000000],realx[1000000],realy[1000000],parent[1000000];
event events[1000000];
long long ans[1000000],best;
pair <int,int> xx[1000000],yy[1000000];
map <int, P> lefts;
set <int> s;
int v,n;
void event_vertical(int x, int yl, int yr) {
    v++;
    events[v].x=x;
    events[v].type=2;
    events[v].y=yl;
    events[v].righty=yr;
}
void event_horizantal_begin(int x, int y, int xx) {
    v++;
    events[v].x=x;
    events[v].type=1;
    events[v].y=y;
    events[v].righty=xx;
}
void event_horizantal_end(int x, int y) {
    v++;
    events[v].x=x;
    events[v].type=3;
    events[v].y=y;
    events[v].righty=0;
}
bool CMP (const event& i, const event& j) {
    return (i.x<j.x || (i.x==j.x && i.type<j.type));
}
void compressX() {
    for (int i=1;i<=n;i++) xx[i]=make_pair(xbegin[i],i);
    for (int i=1;i<=n;i++) xx[i+n]=make_pair(xend[i],i+n);
    sort(xx+1,xx+2*n+1);
    int v=0;
    xx[0]=make_pair(xx[1].first-1,0);
    for (int i=1;i<=2*n;i++) {
        if (xx[i].first!=xx[i-1].first) v++;
        realx[v]=xx[i].first;
        int t=xx[i].second;
        if (t>n) xend[t-n]=v;
        else xbegin[t]=v;
    }
}
void compressY() {
    for (int i=1;i<=n;i++) yy[i]=make_pair(ybegin[i],i);
    for (int i=1;i<=n;i++) yy[i+n]=make_pair(yend[i],i+n);
    sort(yy+1,yy+2*n+1);
    int v=0;
    yy[0]=make_pair(yy[1].first-1,0);
    for (int i=1;i<=2*n;i++) {
        if (yy[i].first!=yy[i-1].first) v++;
        realy[v]=yy[i].first;
        int t=yy[i].second;
        if (t>n) yend[t-n]=v;
        else ybegin[t]=v;
    }
}
void init() {
    cin >> n;
    for (int i=1;i<=n;i++) cin >> xbegin[i] >> ybegin[i] >> xend[i] >> yend[i];
    compressX();
    compressY();
}
void make_events() {
    v=0;
    for (int i=1;i<=n;i++) {
        if (xbegin[i]==xend[i]) event_vertical(xbegin[i],ybegin[i],yend[i]);
        else {
            event_horizantal_begin(xbegin[i],ybegin[i],xend[i]);
            event_horizantal_end(xend[i],ybegin[i]);
        }
    }
    sort(events+1,events+v+1, CMP);
}
int findsum(int x) {
    int s=0;
    while (x>=1) {
        s+=fen[x];
        x=(x & (x-1));
    }
    return s;
}
void md(int x, int y) {
    while (x<=400010) {
        fen[x]+=y;
        x=(x | (x-1))+1;
    }
}
int findset(int x) {
    if (parent[x]==0) return x;
    parent[x]=findset(parent[x]);
    return parent[x];
}
void divide(int y, int l) {
    set<int>::iterator it2=s.upper_bound(y);
    it2--;
    P cnt=lefts[l];
    if (y>l) {
        int r=*it2;
        int nsize=findsum(r)-findsum(l-1);
        lefts[l].right=r;
        lefts[l].number=nsize;
    } else lefts.erase(l);
    if (y<cnt.right) {
        it2++;
        int nl=*it2;
        int nsize=findsum(cnt.right)-findsum(nl-1);
        lefts[nl].right=cnt.right;
        lefts[nl].dsu=cnt.dsu;
        lefts[nl].number=nsize;
    }
}
int main() {
  //  freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    init();
    make_events();
    compcount=0;
    best=0;
    s.insert(0);
    s.insert(2000000);
    lefts[2000000]={2000000,0,0};
    lefts[0]={0,0,0};
    for (int i=1;i<=v;i++) {
        if (events[i].type==1) {
            int y=events[i].y;
            compcount++;
            ans[compcount]=realx[events[i].righty]-realx[events[i].x];
            map<int,P>::iterator it1=lefts.upper_bound(y);
            it1--;
            int l=it1->first;
            if (l<=y && y<=lefts[l].right) divide(y,l);
            s.insert(y);
            lefts[y].right=y;
            lefts[y].dsu=compcount;
            lefts[y].number=1;
            md(y,1);
        }
        if (events[i].type==3) {
            int y=events[i].y;
            map<int, P>::iterator it=lefts.upper_bound(y);
            it--;
            md(y,-1);
            int l=it->first;
            s.erase(y);
            if (lefts[l].right==l) lefts.erase(l);
            else divide(y,l);
        }
        if (events[i].type==2) {
            int yl=events[i].y;
            int yr=events[i].righty;
            if (realy[yr]-realy[yl]>best) best=realy[yr]-realy[yl];
            int nDSU=0;
            int nl=0;
            int nr=0;
            map<int, P>::iterator it=lefts.lower_bound(yl);
            it--;
            int l=it->first;
            P cnt=lefts[l];
            if (cnt.right>=yl && l<=yl) {
                nl=l;
                nr=cnt.right;
                nDSU=findset(cnt.dsu);
                ans[nDSU]+=realy[yr]-realy[yl];
                ans[nDSU]-=findsum(min(cnt.right,yr))-findsum(yl-1)-1;
                lefts.erase(l);
            }
            while (true) {
                map<int, P>::iterator it1=lefts.lower_bound(yl);
                int l=it1->first;
                if (l>yr) break;
                if (lefts[l].right>yr) break;
                if (nl==0) nl=l;
                P cnt=lefts[l];
                nr=cnt.right;
                if (nDSU==0) {
                    nDSU=findset(cnt.dsu);
                    ans[nDSU]+=realy[yr]-realy[yl];
                } else {
                    if (nDSU==findset(cnt.dsu)) ans[nDSU]--;
                    if (nDSU!=findset(cnt.dsu)) ans[nDSU]+=ans[findset(cnt.dsu)];
                    if (nDSU!=findset(cnt.dsu)) parent[findset(cnt.dsu)]=nDSU;
                }
                ans[nDSU]-=cnt.number-1;
                lefts.erase(l);
            }
            it=lefts.upper_bound(yr);
            it--;
            l=it->first;
            cnt=lefts[l];
            if (cnt.right>=yr && l<=yr) {
                if (nl==0) nl=l;
                nr=cnt.right;
                if (nDSU==0) {
                    nDSU=findset(cnt.dsu);
                    ans[nDSU]+=realy[yr]-realy[yl];
                } else {
                    if (nDSU==findset(cnt.dsu)) ans[nDSU]--;
                    if (nDSU!=findset(cnt.dsu)) ans[nDSU]+=ans[findset(cnt.dsu)];
                    if (nDSU!=findset(cnt.dsu)) parent[findset(cnt.dsu)]=nDSU;
                }
                ans[nDSU]-=findsum(yr)-findsum(l-1)-1;
                lefts.erase(l);
            }
            if (nDSU!=0) {
                lefts[nl].right=nr;
                lefts[nl].dsu=nDSU;
                lefts[nl].number=findsum(nr)-findsum(nl-1);
            }
        }
    }
    for (int i=1;i<=compcount;i++)
        if (ans[i]>best) best=ans[i];
    cout << best << endl;
    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <queue>
#include <utility>
#include <fstream>
using namespace std;
struct event {
    int x,type,y,righty;
};
struct P {
    int right,dsu,number;
};
int xbegin[1000000],compcount,fen[1001000],xend[1000000],ybegin[1000000],yend[1000000],realx[1000000],realy[1000000],parent[1000000];
event events[1000000];
long long ans[1000000],best;
pair <int,int> xx[1000000],yy[1000000];
map <int, P> lefts;
set <int> s;
int v,n;
void event_vertical(int x, int yl, int yr) {
    v++;
    events[v].x=x;
    events[v].type=2;
    events[v].y=yl;
    events[v].righty=yr;
}
void event_horizantal_begin(int x, int y, int xx) {
    v++;
    events[v].x=x;
    events[v].type=1;
    events[v].y=y;
    events[v].righty=xx;
}
void event_horizantal_end(int x, int y) {
    v++;
    events[v].x=x;
    events[v].type=3;
    events[v].y=y;
    events[v].righty=0;
}
bool CMP (const event& i, const event& j) {
    return (i.x<j.x || (i.x==j.x && i.type<j.type));
}
void compressX() {
    for (int i=1;i<=n;i++) xx[i]=make_pair(xbegin[i],i);
    for (int i=1;i<=n;i++) xx[i+n]=make_pair(xend[i],i+n);
    sort(xx+1,xx+2*n+1);
    int v=0;
    xx[0]=make_pair(xx[1].first-1,0);
    for (int i=1;i<=2*n;i++) {
        if (xx[i].first!=xx[i-1].first) v++;
        realx[v]=xx[i].first;
        int t=xx[i].second;
        if (t>n) xend[t-n]=v;
        else xbegin[t]=v;
    }
}
void compressY() {
    for (int i=1;i<=n;i++) yy[i]=make_pair(ybegin[i],i);
    for (int i=1;i<=n;i++) yy[i+n]=make_pair(yend[i],i+n);
    sort(yy+1,yy+2*n+1);
    int v=1;
    yy[0]=make_pair(yy[1].first-1,0);
    for (int i=1;i<=2*n;i++) {
        if (yy[i].first!=yy[i-1].first) v++;
        realy[v]=yy[i].first;
        int t=yy[i].second;
        if (t>n) yend[t-n]=v;
        else ybegin[t]=v;
    }
}
void init() {
    cin >> n;
    for (int i=1;i<=n;i++) cin >> xbegin[i] >> ybegin[i] >> xend[i] >> yend[i];
    compressX();
    compressY();
}
void make_events() {
    v=0;
    for (int i=1;i<=n;i++) {
        if (xbegin[i]==xend[i]) event_vertical(xbegin[i],ybegin[i],yend[i]);
        else {
            event_horizantal_begin(xbegin[i],ybegin[i],xend[i]);
            event_horizantal_end(xend[i],ybegin[i]);
        }
    }
    sort(events+1,events+v+1, CMP);
}
int findsum(int x) {
    int s=0;
    while (x>=1) {
        s+=fen[x];
        x=(x & (x-1));
    }
    return s;
}
void md(int x, int y) {
    while (x<=1000000) {
        fen[x]+=y;
        x=(x | (x-1))+1;
    }
}
int findset(int x) {
    if (parent[x]==0) return x;
    parent[x]=findset(parent[x]);
    return parent[x];
}
void divide(int y, int l) {
    set<int>::iterator it2=s.upper_bound(y);
    it2--;
    P cnt=lefts[l];
    if (y>l) {
        int r=*it2;
        int nsize=findsum(r)-findsum(l-1);
        lefts[l].right=r;
        lefts[l].number=nsize;
    } else lefts.erase(l);
    if (y<cnt.right) {
        it2++;
        int nl=*it2;
        int nsize=findsum(cnt.right)-findsum(nl-1);
        lefts[nl].right=cnt.right;
        lefts[nl].dsu=cnt.dsu;
        lefts[nl].number=nsize;
    }
}
int main() {
   // freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    init();
    make_events();
    compcount=0;
    best=0;
    s.insert(0);
    s.insert(2000000);
    lefts[2000000].right=2000000;
    lefts[0].right=0;
    for (int i=1;i<=v;i++) {
        if (events[i].type==1) {
            int y=events[i].y;
            compcount++;
            ans[compcount]=realx[events[i].righty]-realx[events[i].x];
            map<int,P>::iterator it1=lefts.upper_bound(y);
            it1--;
            int l=it1->first;
            if (l<=y && y<=lefts[l].right) divide(y,l);
            s.insert(y);
            lefts[y].right=y;
            lefts[y].dsu=compcount;
            lefts[y].number=1;
            md(y,1);
        }
        if (events[i].type==3) {
            int y=events[i].y;
            s.erase(y);
            map<int, P>::iterator it=lefts.upper_bound(y);
            it--;
            md(y,-1);
            int l=it->first;
            if (lefts[l].right==l) lefts.erase(l);
            else
            if (lefts[l].right==y) {
                set<int>::iterator it=s.lower_bound(y);
                it--;
                lefts[l].right=*it;
                lefts[l].number--;
            }
            else
            if (l==y) {
                set<int>::iterator it=s.lower_bound(y);
                P cnt=lefts[l];
                lefts.erase(l);
                lefts[*it]=cnt;
                lefts[*it].number--;
            }
            else lefts[l].number--;
        }
        if (events[i].type==2) {
            int yl=events[i].y;
            int yr=events[i].righty;
            if (realy[yr]-realy[yl]>best) best=realy[yr]-realy[yl];
            int nDSU=0;
            int nl=0;
            int nr=0;
            int dif=1;
            map<int, P>::iterator it=lefts.lower_bound(yl);
            it--;
            int l=it->first;
            P cnt=lefts[l];
            if (cnt.right>=yl && l<=yl) {
                nl=l;
                nr=cnt.right;
                nDSU=findset(cnt.dsu);
                lefts.erase(l);
            }
            while (true) {
                map<int, P>::iterator it1=lefts.lower_bound(yl);
                int l=it1->first;
                if (l>yr) break;
                if (lefts[l].right>yr) break;
                if (nl==0) nl=l;
                P cnt=lefts[l];
                nr=cnt.right;
                if (nDSU==0) nDSU=findset(cnt.dsu);
                else
                if (nDSU!=findset(cnt.dsu)) {
                    ans[nDSU]+=ans[findset(cnt.dsu)];
                    parent[findset(cnt.dsu)]=nDSU;
                    dif++;
                }
                lefts.erase(l);
            }
            it=lefts.upper_bound(yr);
            it--;
            l=it->first;
            cnt=lefts[l];
            if (cnt.right>=yr && l<=yr) {
                if (nl==0) nl=l;
                nr=cnt.right;
                if (nDSU==0) nDSU=findset(cnt.dsu);
                else
                if (nDSU!=findset(cnt.dsu)) {
                    ans[nDSU]+=ans[findset(cnt.dsu)];
                    parent[findset(cnt.dsu)]=nDSU;
                    dif++;
                }
                lefts.erase(l);
            }
            if (nDSU!=0) {
                lefts[nl].right=nr;
                lefts[nl].dsu=nDSU;
                lefts[nl].number=findsum(nr)-findsum(nl-1);
                ans[nDSU]+=realy[yr]-realy[yl]-findsum(yr)-findsum(yl-1)+dif;
            }
        }
    }
    for (int i=1;i<=compcount;i++)
        if (ans[i]>best) best=ans[i];
    cout << best << endl;
    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <queue>
#include <utility>
#include <fstream>
using namespace std;
struct event {
    int x,type,y,righty;
};
struct P {
    int right,dsu,number;
};
int xbegin[1000000],compcount,fen[1000000],xend[1000000],ybegin[1000000],yend[1000000],realx[1000000],realy[1000000],parent[1000000];
event events[1000000];
long long ans[1000000],best;
pair <int,int> xx[1000000],yy[1000000];
map <int, P> lefts;
set <int> s;
int v,n;
void event_vertical(int x, int yl, int yr) {
    v++;
    events[v].x=x;
    events[v].type=2;
    events[v].y=yl;
    events[v].righty=yr;
}
void event_horizantal_begin(int x, int y, int xx) {
    v++;
    events[v].x=x;
    events[v].type=1;
    events[v].y=y;
    events[v].righty=xx;
}
void event_horizantal_end(int x, int y) {
    v++;
    events[v].x=x;
    events[v].type=3;
    events[v].y=y;
    events[v].righty=0;
}
bool CMP (const event& i, const event& j) {
    return (i.x<j.x || (i.x==j.x && i.type<j.type));
}
void compressX() {
    for (int i=1;i<=n;i++) xx[i]=make_pair(xbegin[i],i);
    for (int i=1;i<=n;i++) xx[i+n]=make_pair(xend[i],i+n);
    sort(xx+1,xx+2*n+1);
    int v=0;
    xx[0]=make_pair(xx[1].first-1,0);
    for (int i=1;i<=2*n;i++) {
        if (xx[i].first!=xx[i-1].first) v++;
        realx[v]=xx[i].first;
        int t=xx[i].second;
        if (t>n) xend[t-n]=v;
        else xbegin[t]=v;
    }
}
void compressY() {
    for (int i=1;i<=n;i++) yy[i]=make_pair(ybegin[i],i);
    for (int i=1;i<=n;i++) yy[i+n]=make_pair(yend[i],i+n);
    sort(yy+1,yy+2*n+1);
    int v=0;
    yy[0]=make_pair(yy[1].first-1,0);
    for (int i=1;i<=2*n;i++) {
        if (yy[i].first!=yy[i-1].first) v++;
        realy[v]=yy[i].first;
        int t=yy[i].second;
        if (t>n) yend[t-n]=v;
        else ybegin[t]=v;
    }
}
void init() {
    cin >> n;
    for (int i=1;i<=n;i++) cin >> xbegin[i] >> ybegin[i] >> xend[i] >> yend[i];
    compressX();
    compressY();
}
void make_events() {
    v=0;
    for (int i=1;i<=n;i++) {
        if (xbegin[i]==xend[i]) event_vertical(xbegin[i],ybegin[i],yend[i]);
        else {
            event_horizantal_begin(xbegin[i],ybegin[i],xend[i]);
            event_horizantal_end(xend[i],ybegin[i]);
        }
    }
    sort(events+1,events+v+1, CMP);
}
int findsum(int x) {
    int s=0;
    while (x>=1) {
        s+=fen[x];
        x=(x & (x-1));
    }
    return s;
}
void md(int x, int y) {
    int s=0;
    while (x<=400010) {
        fen[x]+=y;
        x=(x | (x-1))+1;
    }
}
int findset(int x) {
    if (parent[x]==0) return x;
    parent[x]=findset(parent[x]);
    return parent[x];
}
void divide(int y, int l) {
    if (*s.begin()>y) return;
    set<int>::iterator it2=s.upper_bound(y);
    it2--;
    P cnt=lefts[l];
    if (y>l) {
        int r=*it2;
        int nsize=findsum(r)-findsum(l-1);
        lefts[l].right=r;
        lefts[l].number=nsize;
    }
    if (y<cnt.right) {
        it2++;
        int nl=*it2;
        int nsize=findsum(cnt.right)-findsum(nl-1);
        lefts[nl].right=cnt.right;
        lefts[nl].dsu=lefts[l].dsu;
        lefts[nl].number=nsize;
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    init();
    make_events();
    compcount=0;
    best=0;
    s.insert(2000000);
    lefts[2000000]={2000000,0,0};
    lefts[0]={0,0,0};
    for (int i=1;i<=v;i++) {
        if (events[i].type==1) {
            int y=events[i].y;
            compcount++;
            ans[compcount]=realx[events[i].righty]-realx[events[i].x];
            map<int, P>::iterator it=lefts.begin();
            int l1=it->first;
            if (l1<=y) {
                map<int,P>::iterator it1=lefts.upper_bound(y);
                it1--;
                int l=it1->first;
                if (l<=y && y<=lefts[l].right) divide(y,l);
            }
            s.insert(y);
            lefts[y].right=y;
            lefts[y].dsu=compcount;
            lefts[y].number=1;
            md(y,1);
        }
        if (events[i].type==3) {
            int y=events[i].y;
            s.erase(y);
            map<int, P>::iterator it=lefts.upper_bound(y);
            it--;
            md(y,-1);
            int l=it->first;
            if (lefts[l].right==l) lefts.erase(l);
            else divide(y,l);
        }
        if (events[i].type==2) {
            int yl=events[i].y;
            int yr=events[i].righty;
            if (realy[yr]-realy[yl]>best) best=realy[yr]-realy[yl];
            int nDSU=0;
            int nl=0;
            int nr=0;
            map<int, P>::iterator it=lefts.lower_bound(yl);
            it--;
            int l=it->first;
            P cnt=lefts[l];
            if (cnt.right>=yl) {
                nl=l;
                nr=cnt.right;
                nDSU=cnt.dsu;
                ans[nDSU]+=realy[yr]-realy[yl];
                ans[nDSU]+=findsum(min(cnt.right,yr))-findsum(yl-1)-1;
                lefts.erase(l);
            }
            while (lefts.end()!=lefts.begin()) {
                map<int, P>::iterator it1=lefts.lower_bound(yl);
                int l=it1->first;
                if (l>yr) break;
                if (lefts[l].right>yr) break;
                if (nl==0) nl=l;
                P cnt=lefts[l];
                nr=cnt.right;
                if (nDSU==0) {
                    nDSU=cnt.dsu;
                    ans[nDSU]+=realy[yr]-realy[yl];
                } else {
                    if (nDSU==findset(cnt.dsu)) ans[nDSU]--;
                    ans[nDSU]+=ans[findset(cnt.dsu)];
                    parent[findset(cnt.dsu)]=nDSU;

                }
                if (yr>=cnt.right) ans[nDSU]-=cnt.number-1;
                lefts.erase(l);
            }
            it=lefts.upper_bound(yr);
            it--;
            l=it->first;
            cnt=lefts[l];
            if (cnt.right>=yr) {
                nr=cnt.right;
                if (nDSU==0) {
                    nDSU=cnt.dsu;
                    ans[nDSU]+=realy[yr]-realy[yl];
                } else {
                    if (nDSU==findset(cnt.dsu)) ans[nDSU]--;
                    ans[nDSU]+=ans[findset(cnt.dsu)];
                    parent[findset(cnt.dsu)]=nDSU;
                }
                ans[nDSU]+=findsum(yr)-findsum(l-1)-1;
                lefts.erase(l);
            }
            if (nDSU!=0) {
                lefts[nl].right=nr;
                lefts[nl].dsu=nDSU;
                lefts[nl].number=findsum(nr)-findsum(nl-1);
            }
        }
    }
    for (int i=1;i<=compcount;i++)
        if (ans[i]>best) best=ans[i];
    cout << best << endl;
    return 0;
}