1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <bits/stdc++.h>
using namespace std;

#define MAXN 2000001

int t[MAXN];

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