For given an integer $n$, print all permutations of $\\{1, 2, ..., n\\}$ in lexicographic order.

Constraints

* $1 \leq n \leq 9$

Input

An integer $n$ is given in a line.

Output

Print each permutation in a line in order. Separate adjacency elements by a space character.

Examples

Input

2


Output

1 2
2 1


Input

3


Output

1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Data{
public:
	int v,w;
	ll d;
	char t;
	string name;
	bool operator<(const Data& rhs){
		if(v==rhs.v){
			if(w==rhs.w){
				if(t==rhs.t){
					if(d==rhs.d){
						return name<rhs.name;
					}
					return d<rhs.d;
				}
				return t<rhs.t;
			}
			return w<rhs.w;
		}
		return v<rhs.v;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	vector<int> P(N);
	iota(ALL(P),1);
	REP(i,N-1){
		cout << P[i] << ' ';
	}
	out(P[N-1]);
	
	while(next_permutation(ALL(P))){
		REP(i,N-1){
			cout << P[i] << ' ';
		}
		out(P[N-1]);
	}
	
	return 0;
}
