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
62
import java.io.*;
import java.util.StringTokenizer;

public class tas {

    public static class IN {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st = null;

        private void prepare() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        }

        public int getInt() throws IOException {
            prepare();
            return Integer.parseInt(st.nextToken());
        }

        public long getLong() throws IOException {
            prepare();
            return Long.parseLong(st.nextToken());
        }

        public String getString() throws IOException {
            prepare();
            return st.nextToken();
        }
    }

    public static void reverse(int[] a) {
        int N = a.length;
        int N2 = N >> 1;
        for (int i=0; i < N2; i++) {
            int tn = N - i - 1;
            int tmp = a[i];
            a[i] = a[tn];
            a[tn] = tmp;
        }
    }

    public static void main(String[] args) throws IOException {
        IN in = new IN();
        int n = in.getInt();
        int t = in.getInt();
        int N = 1 << n;
        int[] counts = new int[N];
        for (int i = 0; i< N; i++) counts[i] = in.getInt();
        if (t % 2 == 1) {
            reverse(counts);
        }
        BufferedWriter bf = new BufferedWriter(new OutputStreamWriter(System.out));
        for (int i = 0; i < N-1; i++) {
            bf.write(counts[i] + " ");
        }
        bf.write(counts[N-1] + "\n");
        bf.flush();
    }

}