program r2(input,output);
uses crt;
const n=3;
Type t1=array [1..n,1..n] of longint;
var i,j:integer;
    s0,s1,s2:longint;
    a:t1;
    t,f:boolean;
    vih:char;
{--------------------------------------------------------------------------}
procedure inprov (var x:t1;var f:boolean);
var n,m,z:integer;
    q:char;
    o:boolean;
begin
f:=true;
for n:=1 to 3 do
        begin
        for m:=1 to 3 do
                begin
                x[n,m]:=0;
                o:=true;
                read (q);
                if q='-' then
                        begin
                        o:=false;
                        read (q)
                end;
                while (q<>' ') do
                        begin
                        if (ord(q)<48) or (ord(q)>57) then
                                 begin
                                 f:=false;
                                 break
                                 end;
                        x[n,m]:=10 * x[n,m]+ ord(q) - 48;
                        read (q)
                        end;
                if (not o) and f then x[n,m]:=-x[n,m];
                if not f then break
                end;
        if not f then break
        end;
        writeln ('Inputing is finished');
        writeln
end;
{--------------------------------------------------------------------------}
begin clrscr;
repeat
writeln ('Input matrix:');
writeln ('Matrix is 9 numbers with a spase after each');
f:=true;
inprov (A,f);
readln;
if f then
        begin
        readln;
        s0:=0;
        s1:=0;
        s2:=0;
        t:=true;
        for i:= 1 to n do s0 := s0 + a[1,i];
        for i:= 1 to n do
                begin
                s1:=0;
                s2:=0;
                for j:=1 to n do
                        begin
                        s1 := s1 + a[j,i];
                        s2 := s2 + a[i,j]
                        end;
                if (s1<>s0) or (s2<>s0) then t:=false
                end;
        if t then writeln ('This matrix is a magic square')
                else writeln ('This matrix is not a magic square');
                readln;
        writeln ('Outputing is finished')
end
else
        begin
        writeln ('This input is incorrect');
        writeln ('YOU ARE STUPID!!!');
        writeln
        END;
writeln ('Do you want to continue computings? ');
writeln ('0-no, others-yes');
readln (vih)
until vih='0';
writeln ('thank you for using my programm!');
readln
end.






