program bai_toan;
var
S, S1: string;
i, j, n: integer;
begin
write('Nhap xau S: ');
readln(S);
n := length(S);
for i := n downto 1 do
begin
S1 := S1 + S[i];
end;
for i := n downto 1 do
begin
if S = S1 then break;
S := S + S1[i];
end;
writeln('Xau doi xung ngan nhat la: ', S);
readln;
end.