program Traps;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var s,d1,x1,x2,y1,y2:real;
n,i,kl,i1:integer;
begin
  assign (input,'Traps.in');
  reset (input);
  readln(n);
  for i:=1 to n do
    begin
    s:=0;
     readln (kl);
     for i1:=1 to kl do
     begin
      readln (x2,y2);
      d1:=sqrt(sqr(x2-x1)+sqr(y2-y1));
      s:=s+d1;
      x1:=x2;
      y1:=y2;
      end;
     s:=s+sqrt(sqr(x1)+sqr(y1));
     writeln(s:2:2);
     x1:=0;
     y1:=0;
     end;
end.
