1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    unsigned n, t;
    
    cin >> n >> t;
    
    --n;
    n = 2 << n;
    t = t % 2;
    
    if (t) {
        unsigned tab[n];
        for (int i = 0; i < n; ++i)
            cin >> tab[i];
            
        cout << tab[n-1];
        for (int i = n-2; i >= 0; --i)
            cout << ' ' << tab[i];
    }
    else {
        cin >> t;
        cout << t;
        for (int i = 1; i < n; ++i) {
            cin >> t;
            cout << ' ' << t;
        }
    }
    return 0;
}