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

#define f first
#define s second

typedef long long int64;
typedef vector <int> VI;
typedef pair <int, int> PII;

const int mod = 1e9 + 7;
const int64 INF = 1000000000000000000LL;

const bool DEBUG = false;
#define DB if(DEBUG)

///////////////////////////////////////



int n, k;
int tab[1 << 21];


int main() {
	scanf("%d %d", &n, &k);
	
	for(int i = 0; i < 1 << n; i++)
    scanf("%d", &tab[i]);
  if(k % 2) reverse(tab, tab + (1 << n));
  for(int i = 0; i < 1 << n; i++)
    printf("%d ", tab[i]);
	
	
	
	
}