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
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class tas {

	public static void main(String[] args) {
		try{
			BufferedReader buffReader = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer tokenzier = new StringTokenizer(buffReader.readLine());
			
			int n = Integer.parseInt(tokenzier.nextToken());
			int t = Integer.parseInt(tokenzier.nextToken());

			int cardNumber = 1 << n;
			int cards[] = new int[cardNumber];
			
			tokenzier = new StringTokenizer(buffReader.readLine());
			for(int i = 0; i < cardNumber; i++)
				cards[i] = Integer.parseInt(tokenzier.nextToken());
			
			if((t & 1) == 1){
				int mask = cardNumber - 1;
				int invCards[] = new int[cardNumber];
				for(int i = 0; i < cardNumber; i++)
					invCards[i] = cards[~i & mask];
				cards = invCards;
			}
			
			StringBuilder cardValues = new StringBuilder(2*cardNumber+1);
			cardValues.append(cards[0]);
			for(int i = 1; i < cardNumber; i++)
				cardValues.append(" " + cards[i]);
			
			System.out.println(cardValues);
						
		}catch(Exception e){
			e.printStackTrace();
		}

	}

}