1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
var
        a:array [1..1048576] of longint;
        i,t,n,r:longint;

begin
    readln(n,t);
    r:=1;
    for i:=1 to n do
        r:=r*2;
    n:=r;
    for i:=1 to n do
        read(a[i]);

    if (t mod 2)=0 then begin
        for i:=1 to n do write(a[i],' ');
    end
    else begin
        for i:=n downto 1 do write(a[i],' ');
    end;
end.