1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <cstdio>
#include <vector>
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,b,e) for(int i=b; i<=e; i++)
#define FORD(i,b,e) for(int i=b; i>=e; i--)
using namespace std;

int tab[10000000];

int main(){
	int n,t;
	scanf("%d %d", &n, &t);
	n = (1 << n);

	REP(i,n){
		scanf("%d", &tab[i]);
	}

	if(t%2==0) REP(i,n) printf("%d ", tab[i]);
	else FORD(i,n-1, 0) printf("%d ", tab[i]);
	printf("\n");
}