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
48
49
50
51
52
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,n) for(int i=0; i < int(n); ++i)
#define FO(i,a,b) for(int i=int(a); i<int(b); ++i)

typedef long long ll;
typedef pair<int,int> pii;

typedef vector<int> vi;
typedef vector<vi> vvi;

#define siz size()*1LL

#define fi first
#define se second

#define ASS assert

#define remin(a,b) a=min(a,b)
#define remax(a,b) a=max(a,b)

#define ALL(c) (c).begin(), (c).end()

#define NL '\n'


int n,t;

int main(){
	ios_base::sync_with_stdio(0);
	
	cin >> n >> t;
	
	int num = 1<<n;
	
	vi data(num);
	
	FOR(i,num){
		cin >> data[i];
	}
	
	if(t%2==0){
		FOR(i,num) cout << data[i] << ' ';
	}
	else{
		FOR(i,num) cout << data[num-1-i] << ' ';
	}
	cout << NL;
	
	return 0;
}