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
//https://cpprefjp.github.io/reference/numeric/iota.html ->iota

#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>

int main(){

    int n;
    std::cin>>n;
   
   
    std::vector<int> array;
    for(int i=0;i<n;i++){
        array.push_back(i+1);
    }
   
/*
    std::vector<int> array(n);
    std::iota(array.begin(),array.end(),1);
*/

    for(int i=0;i<n;i++){
        std::cout<<(i?" ":"")<<array[i];
        }
        std::cout<<std::endl;

    while(std::next_permutation(array.begin(),array.end())){
        for(int i=0;i<n;i++){
            std::cout<<(i?" ":"")<<array[i];
        }
        std::cout<<std::endl;
    
    }

/*
    do{
        for(int i=0;i<n;i++){
            std::cout<<(i?" ":"")<<array[i];
        }
        std::cout<<std::endl;;
    }while(std::next_permutation(array.begin(),array.end()));
*/
    return 0;

}

