#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#define ll long long
#define gcd __gcd
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ts cin.tie(nullptr)->sync_with_stdio(false);
#define debug cout<<"HI"<<endl;
const int inf = 1e9;
const ll infll = 1e18;
using namespace std;
vector<int> construct_permutation(ll k){
if(k==1) return {};
if(k==2) return {0};
if(k==3) return {1,0};
if(k==4) return {2,1,0};
vector<int> a;
if(k%4==1){
a=construct_permutation(k-1);
a.insert(a.begin(), a.size());
return a;
} else if(k%4==3){
a=construct_permutation(k-3);
for(auto &x:a) if(x>=2) x++;
a.push_back(2);
return a;
} else {
// k%2==0
a=construct_permutation(k/2);
a.push_back(a.size());
return a;
}
}
// int main(){
// ts
// ll n; cin >> n;
// auto v = construct_permutation(n);
// for(auto &i:v) cout << i << " ";
// return 0;
// }