const
  maxn=1000;
  inputfile='cards.in';
  outputfile='cards.out';
var
  n,i,j,p,s:integer;
  list,temp,order:array[1..maxn]of integer;
begin
  assign(input,inputfile);
  reset(input);
  read(n,s);
  for i:=1 to n do read(list[i]);
  order[1]:=1;
  for i:=2 to n do order[i]:=list[order[i-1]];
  for i:=1 to s do begin
    temp[1]:=1;
    p:=1;
    for j:=2 to n do begin
      p:=p+n div 2+1;
      if p>n then p:=p-n;
      temp[j]:=order[p];
    end;
    order:=temp;
  end;
  for i:=1 to n-1 do list[order[i]]:=order[i+1];
  list[order[n]]:=order[1];
  assign(output,outputfile);
  rewrite(output);
  for i:=1 to n do writeln(list[i]);
  close(output);
end.

