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
#include <cstdio>
#include <iostream>

using namespace std;

int d[2000000];

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int dl = (1 << n);
	for (int i = 0; i < dl; i++) scanf("%d", &d[i]);
	if (k % 2 == 0) {
		for (int i = 0; i < dl; i++) {
			printf("%d ", d[i]);
		}
		printf("\n");
	} else {
		for (int i = dl - 1; i >= 0; i--) {
			printf("%d ", d[i]);
		}
		printf("\n");
	}
	return 0;
}