1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <cstdio>
using namespace std;

int main()
{
	int cards, shuffles;
	scanf("%d%d", &cards, &shuffles);
	cards = 1<<cards;

	int deck[cards];
	for(int i = 0; i < cards; ++i)
		scanf("%d", &(deck[i]));
	
	if(shuffles %2 == 0)
	{
		for(int i = 0; i < cards; ++i)
			printf("%d ", deck[i]);
	}
	else
		for(int i = cards-1; i >= 0; --i)
			printf("%d ", deck[i]);
	printf("\n");
	return 0;
}