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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<algorithm>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<deque>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<vector>
using namespace std;

typedef long long LL;
typedef long double LD;

#define dprintf(...) fprintf(stderr, __VA_ARGS__)

int cond = 1;
#define DB(X) {if(cond){cerr<<"Line:"<<__LINE__<<", "<<#X<<" = "<<X<<endl;}}

int solve() {
	return 0;
}

int main() {
	deque<int> a;
	int n, t; cin >> n >> t;
	for(int x = 1; x <= (1 << n); ++x){
		int v; cin >> v;
		if (t%2) {
			a.push_front(v);
		}
		else {
			a.push_back(v);
		}
	}
	cout << a[0];
	for(int i = 1; i < 1 << n; ++i) {
		cout << " " << a[i];
	}
	return 0;
}