1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include <cstdio>

int n, t, as, a[1 << 20];

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