1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
var
  i, n, t: Longint;
  a:Array[1..1048576] of Longint;
begin
  read(n, t);
  n := 1 shl n;
  for i:=1 to n do
    read(a[i]);

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