/*******************
* what the sigma *
********************/
#include <iostream>
#include <vector>
#include <map>
#include <chrono>
#include <set>
#include <queue>
#include <algorithm>
#include <stack>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
#define lgm cin.tie(0)->sync_with_stdio(0);
#define be(x) x.begin(),x.end()
#define ve vector
#define ll long long
#define ld long double
bool enabledb=0;
#define DB(CODE) cout<<'\t'<<CODE<<endl;
#define SP <<' '<<
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int, int>
#define tii tuple<int,int,int>
#define pll pair<ll,ll>
#define tll tuple<ll,ll,ll>
#define sz(x) ((int)x.size())
#define pb push_back
const ll mod = 1e9+7,maxn=200005;
const ll INF=(ll)9e18;
void shift(ve<int>&v,int a) {
for (auto&x:v) x+=a;
}
ve<int> construct_permutation(ll k) {
if (k==2) {
return {0};
}
if (k==3) {
return {1,0};
}
if (k==5) {
return {2,0,1};
}
ve<int> primes={3,5};
for (auto i:primes) {
if (k%i==0) {
ve<int> hjufghijufgo=construct_permutation(i);
ve<int> jiudfgijdfg=construct_permutation(k/i);
shift(jiudfgijdfg,sz(hjufghijufgo));
for (int i:jiudfgijdfg) {
hjufghijufgo.pb(i);
}
return hjufghijufgo;
}
}
if (k&1) {
ve<int> hi=construct_permutation(k/2);
shift(hi,1);
hi.insert(hi.begin(),0);
hi.insert(hi.begin(),sz(hi));
return hi;
} else {
ve<int> hi=construct_permutation(k/2);
shift(hi,1);
hi.insert(hi.begin(),0);
return hi;
}
}