1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include <bits/stdc++.h>
using namespace std;
int a, b = 1, c;
int tab[1000001];
int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> a >> c;
	for (a; a>0; a--) b*=2;
	for (int i = 0; i < b; i++) {
		cin >> tab[i];
	}
	if (c % 2 == 0)
		for (int i = 0; i < b; i++) cout << tab[i] << " ";
	else
		for (int i = b - 1; i >=0; i--) cout << tab[i] << " ";
	return 0;
}