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;
#define ll long long
#define maxn 2000000
#define Ufor(a, b, i) for(ll i=a;i<b;++i)
#define Dfor(a, b, i) for(ll i=a;i>=b;--i)
ll t[maxn],n,x;
void wczytuj()
{
	scanf("%lld%lld", &n, &x);
	for(ll i=0;i<(1<<n);++i)
		scanf("%lld", &t[i]);
}
int main()
{
	wczytuj();
	if(x%2==0)
	{
		Ufor(0, 1<<n, i) printf("%lld ", t[i]);
	}
	else Dfor((1<<n)-1, 0, i) printf("%lld ", t[i]);
}