program proga;
uses
System.SysUtils;
var
s: string;
i: integer;
arr: TArray;
const
cs = ['.', ',', ':', '-', '"', ';', '!', '?'];
begin
writeln('Напечатай предложение:');
read(s);
arr := s.Split([#32], MaxInt, TStringSplitOptions.ExcludeEmpty);
s := EmptyStr;
for i := high(arr) downto 0 do
begin
if not length(arr) < high(arr) - i + 1 then
if not CharInSet(arr[high(arr) - i + 1], cs) then
arr := arr.Replace(arr[high(arr) - i + 1], '', []);
s := string.Join(#32, [arr, s]);
end;
writeln(s);
end.