var
 s:real;
 x,y,i,k,x1,y1,j,q:integer;
begin
 assign(input,'TRAPS.IN'); reset(input);
 read(q);
 for j:=1 to q do begin
 read(k); x1:=0; y1:=0; s:=0;
 for i:=1 to k do begin
  read(x,y);
  s:=s+sqrt(sqr(x-x1)+sqr(y-y1));
   x1:=x; y1:=y;
  end;
  s:=s+sqrt(sqr(0-x)+sqr(0-y));
    writeln(s:0:2);
    end;
end.
