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
#include<iostream>
#include<list>
#include<stdio.h>
#include<map>
#include<set>
using namespace std;
#define ull unsigned long long int
#define FOR(i,n) for(int i=0;i<n;++i)
#define FORD(i,n) for(int i=(n)-1;i>=0;--i)
#define nil 5000
#define znakow 26
int inline min(int a,int b){return a>b?b:a;}
int inline max(int a,int b){return a<b?b:a;}
int main(){
    int n, t;
    scanf("%d %d",&n,&t);
    int k=1<<n;
    int*s=new int[k];
    FOR(i,k)scanf("%d",s+i);
    if(t&1){
        FORD(i,k)
            printf("%d ",s[i]);
    }else FOR(i,k){
        printf("%d ",s[i]);
    }
    printf("\n");
    return 0;
}