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
#include<bits/stdc++.h>
#define inf 1000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define lli long long
#define sec second
#define fst first
using namespace std;
const int N=1050010;
const int M=300010;
int t[N];
int main()
{
	int n,q;
	scanf("%d%d", &n, &q);
	int p=2;
	for(int i=2;i<=n;i++) p*=2;
	n=p;
	for(int i=1;i<=p;i++) scanf("%d", &t[i]);
	if(q%2==2)
		for(int i=1;i<=n;i++) printf("%d ", t[i]);
	else
		for(int i=n;i>=1;i--) printf("%d ", t[i]);
	
}