program TRAPS;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 f:text;
 i,n,j,kol:integer;
 s,d:real;
 X,Y:integer;
 XX,YY:integer;
begin
 assign(f,'TRAPS.IN');
 reset(f);
 read(f,n);
 XX:=0;
 YY:=0;
 for i:=1 to n do begin
  readln(f,kol);
  s:=0;
  for j:=1 to kol do begin
   readln(f,X,Y);
   d:=sqrt(sqr(X-XX)+sqr(Y-YY));
   s:=s+d;
   XX:=X;
   YY:=Y;
  end;
  s:=s+(sqrt(sqr(XX)+sqr(YY)));
  XX:=0;
  YY:=0;
  writeln(s:4:2);
 end;
 close(f);
end.
 