1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <algorithm>
#include <cstdio>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int a[1 << 20];

int main() {
	int n, t;
	scanf("%d%d", &n, &t);
	int n2 = 1 << n;
	REP(i,n2) scanf("%d", &a[i]);
	if (t & 1) reverse(a, a + n2);
	REP(i,n2) {
		if (i) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
}