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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// TAS2.cpp : Defines the entry point for the console application.
//

#include <cstdio>
using namespace std;

int pow(int a, int n)
{
	int wynik = 1;
	int temp = a;
	while (n > 0)
	{
		if (n & 1) wynik *= temp;
		temp *= temp;
		n >>= 1;
	}
	return wynik;
}

void out(int tab[], int n, bool reversed = false)
{
	if (reversed)
	{
		for (int i = n - 1; i >= 0; i--) printf("%i ", tab[i]);
	}else for (int i = 0; i < n; i++) printf("%i ", tab[i]);
	printf("\n");
}

void solve(int n, int t)
{
	n = pow(2, n);
	int *tab = new int[n];
	for (int i = 0; i < n; i++) scanf("%i", &tab[i]);
	out(tab, n, t % 2 == 0 ? false : true);
	delete[] tab;
}

int main()
{
	
		int n, t;
		scanf("%i %i", &n, &t);
		solve(n, t);
		return 0;
}