1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

vector<int> v;

int main() {
	ios_base::sync_with_stdio(false);
	int n, t;
	cin >> n >> t;
	int p = 1 << n;
	for (int i = 0; i < p; i++) {
		cin >> n;
		v.push_back(n);
	}
	if (t % 2) reverse(v.begin(), v.end());
	for (auto x : v) cout << x << ' ';
}