program division;
type
fa=record
x1:integer;
y1:integer;
x2:integer;
y2:integer;
end;
var
x:array[1..15]of fa;
y:array[1..8,1..8] of real;
n:integer;
ave,sum,ans:real;
procedure init;
var
i,j:integer;
begin
assign(input,'division.in');
reset(input);
assign(output,'division.out');
rewrite(output);
readln(n);
for i:=1 to 8 do
begin
for j:=1 to 8 do
read(y[i,j]);
readln;
end;
x[1].x1:=1; x[1].y1:=1;
x[1].x2:=8; x[1].y2:=8;
close(input);
for i:=1 to 8 do
for j:=1 to 8 do sum:=sum+y[i,j];
ave:=sum/n;
ans:=maxint;
end;
procedure s;
var
i,j,d:integer;
a,b:real;
begin
a:=0;
for i:=1 to n do
begin
b:=0;
for j:=x[i].x1 to x[i].x2 do
for d:=x[i].y1 to x[i].y2 do
b:=b+y[j,d];
a:=a+(b-ave)*(b-ave);
end;
a:=sqrt(a/n);
if a<=ans then ans:=a;
end;
procedure try(k:integer);
var
i,j,temp:integer;
begin
for i:=1 to k-1 do
begin
for j:=x[i].x1 to x[i].x2-1 do
begin
temp:=x[i].x2;
x[k].x1:=j+1;
x[k].y1:=x[i].y1;
x[k].x2:=x[i].x2;
x[k].y2:=x[i].y2;
x[i].x2:=j;
if k=n then s else try(k+1);
x[i].x2:=temp;
end;
for j:=x[i].y1 to x[i].y2-1 do
begin
temp:=x[i].y2;
x[k].x1:=x[i].x1;
x[k].y1:=j+1;
x[k].x2:=x[i].x2;
x[k].y2:=x[i].y2;
x[i].y2:=j;
if k=n then s else try(k+1);
x[i].y2:=temp;
end;
end;
end;
begin
init;
try(2);
writeln(ans:0:3);
close(output);
end.