program traps;

{$APPTYPE CONSOLE}

uses
  SysUtils, System, Math;
type
  xy = record
    x,y:integer;
  end;
var
  fin: TextFile;
  l: string;
  tests,n,i,k: integer;
  dist:double;
  c: array[0..10] of xy;

begin
  { TODO -oUser -cConsole Main : Insert code here }
  AssignFile(fin,'traps.in');
  Reset(fin);
  ReadLn(fin,l);
  tests:=StrToInt(l);
  for i:=1 to tests do begin
    ReadLn(fin,l);
    n:=StrToInt(l);
    dist:=0;
    c[0].x:=0;
    c[0].y:=0;
    for k:=1 to n+1 do begin
      if (k<=n) then begin
        ReadLn(fin,l);
        c[k].x:=StrToInt(copy(l,0,pos(' ',l)-1));
        c[k].y:=StrToInt(copy(l,pos(' ',l)+1,length(l)-pos(' ',l)));
      end else begin
        c[k].x:=0;
        c[k].y:=0;
      end;
      dist:=dist+sqrt(
        sqr(c[k].x-c[k-1].x)+
        sqr(c[k].y-c[k-1].y)
      );
    end;
    WriteLn(dist:length(IntToStr(round(dist))):2);
  end;
  CloseFile(fin);
end.
