program Traps;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var x1,n,m,x,q,e,y1,y,z:integer;
r,w:real;
f:text;
begin
x:=0;
y:=0;
w:=0;
m:=0;
r:=0;
assign(f,'Traps.in');
reset(f);
read(f,z);
repeat begin
read(f,n);
repeat begin
read(f,x1,y1);
q:=x1-x;
e:=y1-y;
w:= sqrt(q*q+e*e);
x:=x1;
y:=y1;
r:=r+w;
m:=m+1;
end;
until m=n;
r:=r+sqrt(x1*x1+y1*y1);
writeln(r:6:2);
m:=0;
x:=0;
y:=0;
w:=0;
r:=0;
end;
until eof(f);
  { TODO -oUser -cConsole Main : Insert code here }
end.
