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

/**
 * Created by michal on 21.11.16.
 */
public class tas {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int n = 1 << Integer.parseInt(input[0]);
        int t = Integer.parseInt(input[1]);
        String[] tab = br.readLine().split(" ");
        if (t % 2 == 0) {
            for(int i=0; i<n; ++i) {
                System.out.print(tab[i] + " ");
            }
        }
        else {
            for(int i=n - 1; i>=0; --i) {
                System.out.print(tab[i] + " ");
            }
        }
    }
}