program matrica(input,output);
const n=10;
type  mat=array [1..n,1..n] of integer;
var i,j,s,p,k:integer; b:boolean; matr:mat;
begin for i:=1 to n do for i:=1 to n do read(matr[i,j]);
      k:=1; b:=true;
      while k<=9 do begin
      for i:=1 to n do if (i+k)<=10 then begin s:=0; p:=0;
      for j:=1 to n do
      begin
      s:=s+matr[i,j]*matr[i+k,j]; p:=p+matr[i,j]*matr[i,j]
      end;
      b:=b and(s=0)and(p=1) end;
      k:=k+1 end;   writeln(b)
end.