1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector<int> perm;

int main() {
  ios::sync_with_stdio(false);
  int n, t;
  cin >> n >> t;
  const int n2 = (1 << n);
  perm.resize(n2);
  for (auto& x : perm)
    cin >> x;
  if (t & 1)
    reverse(perm.begin(), perm.end());
  for (auto x : perm)
    cout << x << " ";
  cout << endl;
  return 0;
}