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
#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define FOR(i,n) REP(i,0,(int)n-1)
#define mp make_pair
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define VI vector<int>
#define fi first
#define se second

int main() {
	ios_base::sync_with_stdio(0);
	int n,t;
	cin>>n>>t;
	vector<int> v;
	FOR(i, (1<<n)) {
		int a;
		cin>>a;
		v.pb(a);
	}
	if( (t%2) == 0)
		FOR(i, (1<<n))
			cout<<v[i]<<" ";
	else 
		for(int i = v.size() - 1; i>=0; i--)
			cout<<v[i]<<" ";
	return 0;
}