1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include <iostream>
using namespace std;

long long n, t, i, x, tab[1050000];
int main(){
    ios_base::sync_with_stdio(0);
    cin>>n>>t;
    x=1<<n;
    for(i=0;i<x;i++)
        cin>>tab[i];
    if(t%2==0)
         for(i=0;i<x;i++)
            cout<<tab[i]<<" ";
    else
         for(i=x-1;i>=0;i--)
            cout<<tab[i]<<" ";
    return 0;
}