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 <cstdio>

using namespace std;

int main()
{
    int n, t, M, *a;
    scanf("%d%d", &n, &t );

    M = 1<<n;

    a = new int [M];

    for( int i=0 ; i<M ; i++ )
        scanf("%d", a+i);

    if( t%2==0 )
        for( int i=0 ; i<M ; i++ )
            printf( "%d ", a[i] );
    else
        for( int i=M-1 ; i>=0 ; i-- )
            printf( "%d ", a[i] );
    printf("\n");



    return 0;
}