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
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

#define prn(...) fprintf(stdout, __VA_ARGS__)
#define dbg(...) fprintf(stderr, "[%s %d] ", __FILE__, __LINE__); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n")

static int a[1050000];

int main(int argc, char* argv[]) {
    int n, t;
    scanf("%d %d", &n, &t);
    n = pow(2, n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    if ((t % 2) != 0) {
        for (int i = n - 1; i >= 0; --i) {
            prn("%d ", a[i]);
        }
    } else {
        for (int i = 0; i < n; i++) {
            prn("%d ", a[i]);
        }
    }
    return 0;
}