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
#include <bits/stdc++.h>

using namespace std;

vector <int> karty;

void tasuj (int s, int e){
	if(e - s == 2)
		printf("%d %d ", karty[e-1], karty[s]);
	else {
		tasuj(s+(e-s)/2, e);
		tasuj(s, s+(e-s)/2);
	}
}

int main(){
	int n, t;
	scanf("%d %d", &n, &t);
	karty.resize(1 << n);
	for(auto &i : karty)
		scanf("%d", &i);
	if (t&1) tasuj(0, 1 << n);
	else 
		for(auto i : karty)
			printf("%d ", i);
}