program Project2; {$APPTYPE CONSOLE} var a:array[1..1000,1..1000] of byte; i,j,n,k,m,x,y:integer; begin assign(Input,'penalty.in'); reset(Input); readln(n,k); for i:=1 to k do begin readln(x,y); a[x,y]:=1; a[y,x]:=1; end; readln(m); close(Input); //for i:=1 to n do a[i,i]:=-1; x:=0; for k:=1 to n do for i:=1 to n do for j:=1 to n do if (a[i,j]>0)and(a[i,k]+a[k,j]>0)and(i<>j)and(i<>k) then inc(x); assign(Output,'penalty.out'); rewrite(Output); for i:=1 to n do begin for j:=1 to n do write(a[i,j],' '); writeln; end; writeln(x); close(Output); end.