program tuan_an_chot;
uses crt;
var a:array[1..100,1..100] of integer;
b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q:integer;
r,s,t,u,v,x,w,y,z:boolean;
begin
clrscr;
write('Nhap m: ');readln(m);
write('Nhap n: ');readln(n);
for i:=1 to m do
for j:=1 to n do begin write('Nhap a[',i,',',j,']: ');
readln(a[i,j]);
end;
writeln('Cac so thuoc day fibonacy la: ');
for i:=1 to m do
for j:=1 to n do
begin
b:=0;
c:=1;
repeat
d:=b+c;
if a[i,j]=d then write(a[i,j],' ');
b:=c;
c:=d;
until d>=a[i,j];
end;
writeln;
writeln('Cac so ... la: ');
for i:=1 to m do
for j:=1 to n do
begin
k:=2;
t:=true;
s:=false;
while (k<=a[i,j]-1) and t do
begin
if a[i,j] mod k=0 then begin
b:=1;
c:=1;
t:=false;
s:=true;
while (c<=n) and not t do
begin
if k=a[b,c] then t:=true;
b:=b+1;
if b>m then begin b:=1;
c:=c+1;
end;
end;
end;
k:=k+1;
end;
if t and s then write(a[i,j],' ');
end;
writeln;
writeln('Cac so hoan hao la:');
for i:=1 to m do
for j:=1 to n do
begin
c:=0;
for b:=1 to a[i,j]-1 do
if a[i,j] mod b=0 then c:=c+b;
if c<a[i,j] then write(a[i,j],' ');
end;
writeln;
writeln('Cac so an chot la:');
for i:=1 to m do
for j:=1 to n do
begin
b:=a[i,j];
c:=0;
repeat
d:=b mod 10;
c:=c+d*d*d;
b:=b div 10;
until b=0;
if c=a[i,j] then write(a[i,j],' ');
end;
readln;
end.