// Arup Guha
// 7/22/2014
// Solution to 2014 SI@UCF Contest Problem: Island Hopping

import java.util.*;

public class hop {

	final public static boolean DEBUG = true;
    final public static int BONUS = 1000;
    final public static int EXTRA = 500;

    public static void main(String[] args) {

        Scanner stdin = new Scanner(System.in);
        int numCases = stdin.nextInt();

        // Go through each case.
        for (int loop=0; loop<numCases; loop++) {

            // Get the first location.
            int flights = stdin.nextInt();
            int[] cur = new int[2];
            cur[0] = stdin.nextInt();
            cur[1] = stdin.nextInt();
            double pts = 0;

            // Add points for each flight.
            for (int i=0; i<flights; i++) {

                // Get next pt.
                int[] next = new int[2];
                next[0] = stdin.nextInt();
                next[1] = stdin.nextInt();

                // Add regular miles.
                double length = getDist(cur, next);
                pts += length;

                // Add bonus.
                if (length > BONUS) pts += EXTRA;

				// Debug check - doubling tolerance here.
				if (DEBUG && Math.abs(length-BONUS)  < 0.02)
					System.out.println("ERRROORRRR!!!");

                // Update for next iteration.
                cur = next;
            }

            // The result.
            System.out.println(pts);
        }
    }

    // Assumes pt1 and pt2 have size 2. Returns distance between the pts.
    public static double getDist(int[] pt1, int[] pt2) {
        return Math.sqrt( (pt1[0]-pt2[0])*(pt1[0]-pt2[0]) + (pt1[1]-pt2[1])*(pt1[1]-pt2[1]) );
    }
}
