1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);

	unsigned long long n, t;

	cin >> n >> t;
	n = 1 << n;

	auto print = [](int a) { cout << a << " "; };
	auto get = []() { int val; cin >> val; return val;};

	if (t % 2)
	{
		vector<int> v;
		v.reserve(n);
		for (int i = 0; i < n; i++)
			v.push_back(get());
		for_each(v.rbegin(), v.rend(), print);
	}
	else
	{
		for (int i = 0; i < n; i++)
			print(get());
	}

	cout << endl;
	return 0;
}