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

inline int read() {
  static char ch;
  while ((ch = getchar()) < '0' || ch > '9');
  int res = ch - 48;
  while ((ch = getchar()) >= '0' && ch <= '9')
    res = res * 10 + ch - 48;
  return res;
}

inline void write(int x) {
  static char c[15];
  int len = 0;
  while (x != 0) c[++len] = '0' + (x % 10), x /= 10;
  while (len > 0) putchar(c[len--]);
  putchar(' ');
}

const int N = 20;
int n, t, m, a[1 << N];

int main() {
  n = read(), t = read();
  m = 1 << n;
  for (int i = 0; i < m; ++i) a[i] = read();
  if (t & 1) for (int i = m - 1; i >= 0; --i) write(a[i]);
  else for (int i = 0; i < m; ++i) write(a[i]);
  putchar('\n');
  return 0;
}