Const
Letters = ['a'..'z', 'A'..'Z'];
LineEnds = [#13, #10, #0, '.'];
MAX_LEN = 255;
var
txt: array [0..MAX_LEN] of char;
bnd: array [0..MAX_LEN, 0..1] of integer;
tsz, bsz: integer; // размеры массивов
isLetter, isWord, f1, f2: boolean;
i, j: integer;
begin
repeat
read(txt[tsz]);
// Определение границ слов
isLetter := txt[tsz] in Letters;
if isLetter and not isWord then
bnd[bsz, 0] := tsz;
if isWord and not isLetter then begin
bnd[bsz, 1] := tsz;
bsz := bsz + 1;
end;
isWord := isLetter;
tsz := tsz + 1;
until txt[tsz-1] in LineEnds;
if bsz > 1 then begin
for i := 0 to bsz-2 do begin
j := 0; f2 := true;
f1 := (bnd[bsz-1, 1] - bnd[bsz-1, 0]) = (bnd[i, 1]-bnd[i, 0]); // совпадение длин
while (j < bnd[i, 1] - bnd[i, 0]) and f2 do begin
f1 := f1 and (txt[bnd[i, 0] + j] = txt[bnd[bsz-1, 0] + j]);
f2 := f2 and (LowCase(txt[bnd[i, 0] + j]) = Chr(Ord('a') + j));
j := j + 1;
end;
// вывод
if f2 and not f1 then begin
for j := bnd[i, 0] to bnd[i, 1] - 1 do
write(txt[j]);
writeln;
end;
end;
end;
end.