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 <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* class */
/* constant */

const int INF = 1 << 30;
const int MAX = 100000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */
void printVec(vector<int> &vec);
/* main */
int main() {

    int N; cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) v[i] = i+1;

    do {
        printVec(v);
    } while (next_permutation(v.begin(), v.end()));

}

void printVec(vector<int> &vec) {

    for (int i = 0; i < vec.size(); i++) {
        if (i) cout << ' ';
        cout << vec[i];
    } cout << '\n';
}

