1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

vector <int> V;

int main()
{
  ios_base::sync_with_stdio(0);
  int n,t,z,a;
  cin >> n >> t;
  z=pow(2,n);
  for (int i=0;i<z;i++)
  {
    cin >> a;
    V.push_back(a);
  }
  if (t%2==1) for (int i=z-1;i>=0;i--) cout << V[i] << " ";
  else for (int i=0;i<z;i++) cout << V[i] << " ";
}