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
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define pi pair<int,int>
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define pl pair<long long,long long>
#define pb push_back

int t[2000005];

int main()
{
    int n,k,a;

    scanf ("%d%d", &n, &k);
    n=1<<n;

    for (a=0; a<n; a++)
        scanf ("%d", &t[a]);

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

    return 0;
}