#include<bits/stdc++.h>
using namespace std;

int f;

void LNR(int n)
{
    if(2 * n >= pow(2, f) - 1){
        cout << n << " ";
        return;
    }
    LNR(2 * n);
    cout << n << " ";
    LNR(2 * n + 1);
}

void NLR(int n)
{
    cout << n << " ";
    if(2 * n >= pow(2, f)){
        return;
    }
    NLR(2 * n);
    NLR(2 * n  + 1);
}

void LRN(int n)
{
    if(n >= pow(2, f)) return;
    LRN(2 * n);
    LRN(2 * n + 1);
    cout << n << " ";
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> f;
    LNR(1);
    cout << "\n";
    NLR(1);
    cout << "\n";
    LRN(1);
}
