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 <cstdio>
#include <array>
#include <algorithm>
using namespace std;

struct lambda{void operator() (int i) {printf(" %d",i);}};
int main(void){
    int i,n;
    array<int,9>v{1,2,3,4,5,6,7,8,9};

    scanf("%d",&n);
    do{
        printf("%d",v[0]);
        for_each(v.begin()+1,v.begin()+n,lambda());
        printf("\r\n");
    }while(next_permutation(v.begin(),v.begin()+n));

    return 0;
}
