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
#include<bits/stdc++.h>
using namespace std;
#define int long long

void swp(int* bg, int *mid, int *end) {
  while(mid != end) {
    swap(*bg, *mid);
    bg++;mid++;
  }
}
void shuffle(int*bg, int *end) {
  if (bg + 1 == end) return;
  int* mid = bg+(end-bg)/2;
  shuffle(bg, mid);
  shuffle(mid, end);
  swp(bg, mid, end);
}
int a[1<<21];
main() {
  int n, t;
  scanf("%lld %lld", &n, &t);
  int pot = (1<<n);
  for (int i = 0; i <pot;i++)
    scanf("%lld", a+i);
  if (t%2) shuffle(a, a+pot);
  for (int i = 0; i <pot;i++)
    printf("%lld ", a[i]);
  printf("\n");
}