var a:array[1..10]of integer;i,k,i1:integer;beginfor i:=1 to 10 do readln(a[i]);
for i:=10 downto 1 do if a[i]<>0 then begin k:=a[i]; i1:=i; break; end;
a[i1]:=a[1];a[1]:=k;for i:=1 to 10 do write(a[i],' ');end.
var a:array[1..10]of integer;
i,k,i1:integer;
begin
for i:=1 to 10 do readln(a[i]);
for i:=10 downto 1 do if a[i]<>0 then begin k:=a[i]; i1:=i; break; end;
a[i1]:=a[1];
a[1]:=k;
for i:=1 to 10 do write(a[i],' ');
end.