#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void recalculate_permutation(vector<int> &p)
{
map<int, int> mp;
int t=0;
for (auto x:p) mp[x]=0;
for (auto &[x, y]:mp) y=t++;
for (int i=0; i<p.size(); i++) p[i]=mp[p[i]]; //cout<<p[i]<<' ';
// cout<<'\n';
}
std::vector<int> construct_permutation(long long k)
{
vector<int> b, res;
while (k) b.push_back(k%2), k/=2;
for (int i=b.size()-2; i>=0; i--)
{
res.push_back(1e9);
if (b[i]) res.push_back(-1);
recalculate_permutation(res);
}
return res;
}
/*
3 bit to encode one data
*/