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

using namespace std;

#define MAXS 1100000
int n, k, s, tab[MAXS];

int main() {
	scanf("%d%d", &n, &k);
	s = 1 << n;
	for(int i = 0; i < s; ++i) {
		scanf("%d", &tab[i]);
	}
	for(int i = 0; i < s; ++i) {
		printf("%d ", tab[k%2?s-i-1:i]);
	}
}