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

int main() {
	std::ios_base::sync_with_stdio(false);
	int n, t;
    std::cin >> n >> t;
    if (t & 1) {
		std::vector<int> v(1 << n);
		for (auto&& a : v) {
			std::cin >> a;
		}
		for (auto it = v.rbegin(), last = v.rend(); it != last; ++it) {
			std::cout << *it << ' ';
		}
    } else {
		for (int i = 1 << n; i--;) {
			int a;
			std::cin >> a;
			std::cout << a << ' ';
		}
    }
    return 0;
}