1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include <cstdio>

int tab[(1<<20)+5];

int main() {
   
    int p, n;
    scanf("%d%d", &p, &n);
    int x = 1<<p;
    
    for(int i = 1; i <= x; i++) scanf("%d", &tab[i]);
    
    if(n % 2 == 1) for(int i = x; i >= 1; i--) printf("%d ", tab[i]);
    else for(int i = 1; i <= x; i++) printf("%d ", tab[i]);
    printf("\n");
    
    return 0;
}