1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <bits/stdc++.h>

using namespace std;

const int N = (1 << 20) + 7;

int n, q;
int tab[N];

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