1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include<cstdio>

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

	return 0;
}