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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <ctime>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
#include <utility>
#include <queue>
#include <list>
#include <iomanip>
#include <set>

#define PI 3.14159265
#define MAXTAB 1048577

using namespace std;

int t, n, pow2[30];
int tab[MAXTAB];

inline void precalc()
{
  pow2[0] = 1;
  for (int i = 1; i < 30; ++i)
    pow2[i] = pow2[i-1]*2;
}

inline void read_input()
{
  scanf("%d %d", &n, &t);
  for (int i = 0; i < pow2[n]; ++i)
    scanf("%d", &(tab[i]));
}

void solve()
{
  if (t % 2 == 1)
  {
    printf("%d", tab[pow2[n]-1]);
    for (int i = 1; i < pow2[n]; ++i)
      printf(" %d", tab[pow2[n]-i-1]);
    printf("\n");
  }
  else
  {
    printf("%d", tab[0]);
    for (int i = 1; i < pow2[n]; ++i)
      printf(" %d", tab[i]);
    printf("\n");
  }
}


int main(int argc, const char *argv[])
{
  precalc();
  read_input();
  solve();
  return 0;
}