1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
program potalgtasowanie;
var
a, b, c, d: longint;
t: array[1..1048576] of longint;
begin
readln(a, b);
b:=b mod 2;
c:=1; for d:=1 to a do c:=c*2;
for d:=1 to c do if b=0 then read(t[d]) else read(t[c-d+1]);
for d:=1 to c do write(t[d], ' ')
end.