uses crt;
var i,n:longint;
a:array[1..100] of longint;
function snt(x:longint):boolean;
var t1:longint;
begin
if x<2 then snt:=false
else
begin
snt:=true;
for t1:=2 to round(sqrt(x)) do
if x mod t1=0 then exit(false)
end;
end;
function sdx(x:longint):boolean;
var st:string;
t2:longint;
begin
sdx:=true;
str(x,st);
for t2:=1 to length(st) div 2 do
if st[t2]<>st[length(st)-t2+1] then exit(false);
end;
BEGIN
clrscr;
write('Nhap n:'); readln(n);
for i:=1 to n do
begin
write('Nhap a[',i,']');
readln(a[i]);
end;
writeln('Cac so nguyen to co trong day:');
for i:=1 to n do
if snt(a[i]) then writeln('so ',a[i],' vi tri ',i);
writeln('Cac so doi xung co trong day:');
for i:=1 to n do
if sdx(a[i]) then write(a[i],' ');
readln
END.