1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, t;
	scanf("%d %d", &n, &t);
	vector<int> V;

	V.reserve(1<<n);
	for(int i=0; i<(1<<n); i++) {
		int x;
		scanf("%d", &x);
		V.push_back(x);
	}
	if(t&1) reverse(V.begin(), V.end());

	for(auto x : V) printf("%d ", x);
	puts("");
}