uses
  SysUtils;
var
l:real;
x1,y1,x2,y2,k,n,i,i1:integer;
begin
assign(input,'traps.in'); reset(input);
read(n);
for i:=1 to n do
  begin
     read(k);
     x1:=0; y1:=0; l:=0;
      for i1:=1 to k do
        begin
          read(x2,y2);
          l:=l+(sqrt(sqr(x2-x1)+sqr(y2-y1)));
          x1:=x2; y1:=y2;
         end;
        l:=l+(sqrt(sqr(x1)+sqr(y1)));
        writeln(l:3:2);
    end;
end.
