import java.io.BufferedInputStream; import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; public class Main { public static final int C = 1000000007; static final int CY = 1000000000; //static boolean MAP[][]; static int N; static int M; static int MAX = -1; //static int tic[][]; static int X[]; static int Y[]; static double W[]; //static int max; static long DP[]; static int ST[][]; //static int p[]; //static ArrayList> al; static TreeMap> hm; //static ArrayList al; //static int a[][]; //static char[][] ch; //static ArrayList> al; //static String a[]; //static String str; public static void main(String[] args) { //StringBuilder sb = new StringBuilder(); BufferedInputStream bs = new BufferedInputStream(System.in); Scanner sc = new Scanner(bs); int x0 = sc.nextInt(); int y0 = sc.nextInt(); N = sc.nextInt(); X = new int[N+1]; Y = new int[N+1]; W = new double[N+1]; X[0] = x0; Y[0] = y0; for (int i=1; i <= N; i++) { X[i] = sc.nextInt(); Y[i] = sc.nextInt(); W[i] = sc.nextDouble(); } double ans = 0; long num = 1; for (int i=1; i <= N; i++) { num *= i; ans += W[i]; } int ar[] = new int[N+1]; double sum = 0; int x=X[0], y=Y[0]; for (int i=0; i < N; i++){ int mi = 0; if (i==0) { double max = 0; for (int t=1; t <= N; t++) { if (ar[t] != 0) continue; if (max < dist(y, x, Y[t], X[t]) || (max == dist(y, x, Y[t], X[t])&& W[t] < W[mi])) { max = dist(y, x, Y[t], X[t]) ; mi = t; } } } else { double min = 1000000; for (int t=1; t <= N; t++) { if (ar[t] != 0) continue; if (min > dist(y, x, Y[t], X[t]) || (min == dist(y, x, Y[t], X[t])&& W[t] < W[mi])) { min = dist(y, x, Y[t], X[t]) ; mi = t; } } } double dis = dist(y,x,Y[mi],X[mi]); ans += dis * (sum + 100)/120; sum += W[mi]; ar[mi] = 1; x = X[mi]; y = Y[mi]; } ans += dist(y, x, X[0], Y[0]) * (sum + 100)/120; System.out.println(ans); } static int dist(int y1, int x1, int y2, int x2) { return Math.abs(y1 - y2) + Math.abs(x1 - x2); } }