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

int cards[1<<20];

int main() {
	int n;
	int t;
	scanf("%i %i", &n, &t);
	int pn = 1 << n;

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

	if( t %2 != 1)
		for(int i = 0; i < pn; ++i)
			printf("%i ", cards[i]);
		else
		for(int i = 0; i < pn; ++i)
			printf("%i ", cards[pn-i-1]);


	return 0;
}