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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

public class tas {

	private static InputStream in;
	
	public static void main(String[] args) throws IOException {
		
		in = new BufferedInputStream(System.in);
		
		int n = nextInt();
		
		int t = nextInt();
		
		int num = (int) Math.pow(2,  n);
		
		StringBuilder sb = new StringBuilder();
		
		if (t % 2 == 0) {
			for (int i = 0; i < num; i++) {
				sb.append(nextInt()).append(" ");
			}
			out(sb);
			return;
		}
		
		int[] a = new int[num];
		
		for (int i = 0; i < num; i++) {
			a[i] = nextInt();
		}
		
		for (int i = num - 1; i >= 0; i--) {
			sb.append(a[i]).append(" ");
		}
		out(sb);
		
	}

	private static void out(StringBuilder sb) throws IOException {
		System.out.println(sb.toString());
		in.close();
	}
	
	private static int nextInt() throws IOException {
	    int ret = 0;
	    boolean dig = false;

	    for (int c = 0; (c = in.read()) != -1; ) {
	        if (c >= 48 && c <= 57) {
	            dig = true;
	            ret = ret * 10 + c - 48;
	        } else if (dig) break;
	    }

	    return ret;
	}
	
}