program traps;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
a,c,j,i,x1,x2,y1,y2: integer;
rez,q,w,e:real;
begin
assign(input,'traps.in');reset(input);

read (c);
for i :=1 to c do begin
  read (a);
  x1:=0;
  y1:=0;
  rez:=0;
  for j:=1 to a do begin
    read(x2);
    read(y2);
    rez := rez +sqrt(sqr(x2-x1)+sqr(y2-y1));
    y1:=y2;
    x1:=x2;
  end;
    rez := rez +sqrt(sqr(0-x1)+sqr(0-y1));
    write(rez:3:2);
    writeln;
end;

  { TODO -oUser -cConsole Main : Insert code here }
end.
