program traps;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 f:text;
 i,j,n,a,l,x1,x2,y1,y2:integer;
 r:real;
begin
 assignfile(f,'traps.in');
 reset(f);
 readln(f,n);


 For i:=1 to n do begin
   readln(f,a);
   x1:=0;
   y1:=0;
   r:=0;
   For j:=1 to a do begin

        readln(f,x2,y2);
        r:=r+(sqrt(sqr(x1-x2)+sqr(y1-y2)));
        x1:=x2;
        y1:=y2;

   end;
    r:=r+(sqrt(sqr(x1)+sqr(y1)));
   writeln(r:0:2);
 end;
 
 closefile(f);
end.
