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
#include "stdio.h"

using namespace std;

int main() {
  int n, t;
  int cards[2000000];


  scanf("%d", &n);
  scanf("%d", &t);

  int cards_count = 1 << n;

  for (int i = 0; i < cards_count; i++) {
    scanf("%d", &cards[i]);
  }

  if (t % 2 == 0 ) {
    for (int i = 0; i < cards_count; i++) {
      printf("%d ", cards[i]);
    }
  }
  else {
    for (int i = 0; i < cards_count; i++) {
      printf("%d ", cards[cards_count - i - 1]);
    }
  }

return 0;
}