uses crt;
const n=50;
const k=8;
type posl=array[1..400] of char;
var a:posl;
    m:integer;


procedure vvod(var a:posl;var l:integer);
var c:char;
begin
writeln('vvedite posl');
a[1]:=' ';
l:=2;
read(c);
a[l]:=c;
while c<>'.' do
begin
read(c);
l:=l+1;
if (a[l-1]=' ') and (c=' ') then l:=l-1
  else a[l]:=c;
end;
end;


procedure vivod(var a:posl;l:integer);
var sn,s1:string[8];
    q,i:integer;
begin
i:=l;
while a[i]<>' ' do
i:=i-1;

sn:='';
for i:=l-1 downto i+1 do
sn:=a[i]+sn;

s1:='';
q:=0;
for i:=1 to l do
begin
if a[i]=' ' then
  begin
  if (s1<>sn)and (pos(s1,'rstuvwxyz')<>0) then
  begin                                                                     5
  write(s1,'  ');
  q:=9;
  end;
  s1:='';
  end
else
s1:=s1+a[i];
end;
if q=0 then writeln('net sovpadenii');
end;



begin
repeat
clrscr;
vvod(a,m);
vivod(a,m);
writeln;
writeln('repeat?');
until readkey='n';
end.
