const fi='gicungduoc.inp';
fo='gicungduoc.out';
var a,i:longint;
function checkprime(x:longint):boolean;
var i:longint;
begin
if x<2 then exit(false);
for i:=2 to trunc(sqrt(x)) do if x mod i = 0 then exit(false);
exit(true);
end;
function hoanhao(n:longint):boolean;
var x,dem,c:longint;
begin
dem:=0;
for x:=1 to n-1 do
if n mod x=0 then
dem:=dem+x;
if dem=n then exit(true);
exit(false);
end;
function doixung(x:longint):boolean;
var c:longint;
s:ansistring;
begin
str(x,s);
for c:=1 to length(s) div 2 do
if s[1+c-1]<>s[length(s)-c+1] then exit(false);
exit(true);
end;
function chinhphuong(x:longint):boolean;
begin
if sqrt(x) = trunc(sqrt(x)) then exit(true);
exit(false);
end;
begin
assign(input,fi);
reset(input);
read(a);
close(input);
assign(output,fo);
rewrite(output);
if doixung(a) then writeln('Doi xung') else writeln('Khong doi xung');
write('Cac so nguyen to tu 1 den a la: ');
for i:=1 to a do
if checkprime(i) then write(i,' ');
writeln;
write('Cac so hoan hao tu 1 den a la: ');
for i:=1 to a do
if hoanhao(i) then write(i,' ');
writeln;
write('Cac so chinh phuong tu 1 den a la: ');
for i:=1 to a do
if chinhphuong(i) then write(i,' ');
writeln;
write('Cac so doi xung tu 1 den a la: ');
for i:=1 to a do
if doixung(i) then write(i,' ');
close(output);
end.