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
#include <stdint.h>
#include <iostream>
#include <vector>


int main()
{
	std::ios_base::sync_with_stdio(0);

	uint32_t N = 0;
	uint32_t T = 0;

	std::cin >> N;
	std::cin >> T;

	std::vector<uint32_t> vec(2 << (N - 1));

	for (size_t i = 0; i < vec.size(); ++i)
		std::cin >> vec[i];

	if (T % 2 == 0)
	{
		for (const auto &v : vec)
			std::cout << v << " ";
	}
	else
	{
		for (auto v = vec.rbegin(); v != vec.rend(); ++v)
			std::cout << *v << " ";
	}

	return 0;
}