program TRAPS;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  ufo = record
    x, y : integer;
  end;

var
  i, n : integer;

function len (x1, y1, x2, y2 : integer) : real;
begin
  result := sqrt(sqr(x2-x1)+sqr(y2-y1));
end;

procedure calc;
var
  a : array [1..20] of ufo;
  k, i : integer;
  L : real;

begin
  fillchar(a, sizeof(a), 0);

  readln(k);

  a[1].x := 0; a[1].y := 0;

  for i:=2 to k+1 do readln(a[i].x, a[i].y);

  inc(k, 2);

  a[k] := a[1];

  L := 0;

  for i:=2 to k do L := L + len(a[i-1].x, a[i-1].y, a[i].x, a[i].y);

  writeln(L:0:2);
end;

begin
  reset(input, 'TRAPS.IN');
  readln(n);

  for i:=1 to n do calc();
end.
