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 <cstdio>
#include <iostream>
#include <vector>
using namespace std;

typedef long long int LL;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  LL n;
  LL t;
  std::cin >> n >> t;
  LL _size = 2;
  std::vector<LL> number;
  for (int i = 1; i < n; i++) {
    _size *= 2;
  }
  for (int i = 0; i < _size; ++i) {
    int a;
    std::cin >> a;
    number.push_back(a);
  }
  if (t % 2 == 1) {
    LL mid = _size / 2;
    for (int i = _size - 1; mid <= i; --i) {
      std::cout << number[i] << " ";
    }
    for (int i = mid - 1; i >= 0; --i) {
      std::cout << number[i] << " ";
    }
  } else {
    for (int i = 0; i < _size; ++i) {
      std::cout << number[i] << " ";
    }
  }

  return 0;
}