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
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ul;
typedef unsigned int ui;
#define s second
#define f first
#define PB push_back
#define REP(x,y) for(int x=0;x<(y);x++)
#define ROF(x,y) for(int x=(y);x>=0;x--)
#define FOR(x,y,z) for(int x=(y);x<(z);x++)
#define INT(x) int x;scanf("%d",&x)
#define LL(x) long long x;scanf("%lld",&x)
#define STR(x) string x; cin>>x;
#define CZ(x) char x; cin >> x;
const ll hsz=996662137;
const ll X=42;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,pii> piii;
pll expgcd(ll a,ll b){
    if(b==0)return pll(1,0);
    pll x=expgcd(b,a%b);
    return pll(x.s,x.f-(a/b)*x.s);
}

vector<int> vec;

int main(){
    INT(n);INT(t);
    int x=(1<<n);
    REP(i,x){
        INT(a);
        vec.PB(a);
    }
    if(t&1)ROF(i,vec.size()-1)printf("%d ",vec[i]);
    else REP(i,vec.size())printf("%d ",vec[i]);
}