1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
  int n;
  int t;
  scanf("%d%d", &n, &t);
  const int N = 1 << n;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) scanf("%d", &a[i]);
  if (t % 2 != 0) reverse(a.begin(), a.end());
  for (int i = 0; i < N; ++i) {
    if (i > 0) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
  return 0;
}