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

public class tas
{

    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int t = in.nextInt();
        in.nextLine();
        int cardsNumber = 1 << n;
        int[] array = new int[cardsNumber];
        for (int i = 0; i < cardsNumber; i++)
        {
            array[i] = in.nextInt();
        }
        
        if ((t & 1) == 0)
        {
            for (int i = 0; i < cardsNumber; i++)
            {
                System.out.print(array[i] + " ");
            }
        }
        else
        {
            for (int i = 0; i < cardsNumber; i++)
            {
                System.out.print(array[cardsNumber - 1 - i] + " ");
            }
        }
    }
}