program ed;
uses crt;
const n=3;
var mag,sfd,sbd:longint;
a:array[1..n,1..n] of integer;
i,j:integer;
function sumrow(const i,m:integer):longint;
var j:integer;
sum:longint;
Begin sum:=0;
for j:=1 to m do inc(sum,a[i,j]);
sumrow:=sum;
end;
function sumcolumn(const j,n:integer):longint;
var i:integer;
sum:longint;
Begin sum:=0;
for i:=1 to n do inc(sum,a[i,j]);
sumcolumn:=sum;
end;
Begin clrscr;
randomize;
for i:=1 to n do for j:=1 to n do a[i,j]:=random(10);
for i:=1 to n do begin for j:=1 to n do write(a[i,j]:3);
writeln;
end;
mag:=n*(sqr(n)+1) div 2;
i:=1;
while (i<=n) and (sumrow(i,n)=mag) and (sumcolumn(i,n)=mag) do inc(i);
sfd:=0;
sbd:=0;
for j:=1 to n do begin inc(sfd,a[j,j]);
inc(sbd,a[j,n-j+1]);
end;
if (i>n) and (sfd=sbd) and (sfd=mag) then writeln('magic') else writeln('not magic');
readln;
End.