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
#include <iostream>
#include <vector>
#include <string>

int main()
{
	int n, t;
	std::cin >> n >> t;

	int two_to_n = 1;
	for(int i_n = 0; i_n < n; ++i_n)
		two_to_n <<= 1;

	std::vector<std::string> cards(two_to_n);

	for(int i_n = 0; i_n < two_to_n; ++i_n)
		std::cin >> cards[i_n];

	if((t % 2) == 0)
	{
		std::cout << cards[0];
		for(int i_n = 1; i_n < two_to_n; ++i_n)
			std::cout << ' ' << cards[i_n];
	}
	else
	{
		std::cout << cards[two_to_n - 1];
		for(int i_n = 1; i_n < two_to_n; ++i_n)
			std::cout << ' ' << cards[two_to_n - 1 - i_n];
	}
}