1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <cstdio>
int n, k, tab[2000001];

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