1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Karol Kosinski
#include <cstdio>
#define FR(i,a,b) for(int i=(a);i<(b);++i)
#define FD(i,b,a) for(int i=(b)-1;i>=(a);--i)
using namespace std;

int A[1234567];

int main()
{
        int n, t;
        scanf("%d%d", &n, &t);
        n = (1 << n);
        FR(i,0,n)
                scanf("%d", A + i);
        if (t % 2 == 1)
                FD(i,n,0)
                        printf("%d ", A[i]);
        else
                FR(i,0,n)
                        printf("%d ", A[i]);
        printf("\n");
        return 0;
}