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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <bits/stdc++.h>

#define double long double
#define LL long long
#define MP make_pair
#define ST first
#define ND second
#define PII pair<LL,LL >
#define PPIII pair<PII,int>
#define PPIIPII pair<PII,PII>
#define PIB pair<int,bool>
#define PIS pair<int,string>
#define PB push_back
#define VI vector<LL>
#define VVI vector<VI>
#define VLL vector<long long>
#define VVLL vector<VLL>
#define VB vector<bool>
#define VPII vector<PII>
#define VPPIII vector<PPIII>
#define VPPIIPII vector<PPIIPII>
#define VPIB vector<PIB>
#define VPIS vector<PIS>
#define SI set<int>
#define SPII set<PPIII>
#define VS vector<string>
#define PB push_back
#define INF (LL) 1000000000000
#define MOD 2000007
#define ALL(c) c.begin(),c.end()
#define NWD __gcd
#define SIZE 1000000

using namespace std;

void rek(int k, int t)
{
	int a;
	cin>>a;
	if(t)
	cout<<a<<" ";
	if(k)
		rek(k-1, t);
	if(!t)
	cout<<a<<" ";

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    int n, t;
    cin>>n>>t;
	n=1<<n;

	rek(n-1, 1 - (t&1));



	return 0;

}