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
import java.util.Scanner;

public class tas{
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int t = in.nextInt();

        int count = 1 << n;
        int[] nums = new int[count];

        for (int i = 0; i < count; ++i)
            nums[i] = in.nextInt();

        if (t % 2 == 1)
        {
           for (int i = 0; i < nums.length / 2; ++i)
           {
               nums[i] = nums[i] ^ nums[nums.length - i - 1];
               nums[nums.length - i - 1] = nums[nums.length - i - 1] ^ nums[i];
               nums[i] = nums[i] ^ nums[nums.length - i - 1];
           }
        }

        for (Integer num : nums) {
            System.out.print(num + " ");
        }
    }
}