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

using namespace std;

int main() {
	int n,t;
	vector<int> cards;

	scanf("%i %i",&n,&t);

	int m = n>=1 ? 1 << n:1;
	int a;
	for(int i = 0;i<m;i++) {
		scanf("%i",&a);
		cards.push_back(a);
	}

	for(int i = 0;i<cards.size();i++) {
		printf("%i ",cards[t%2 == 0 ? i:cards.size()-i-1]);
	}


	return 0;
}