import java.util.*; import java.io.*; public class Main { static int x0; static int y0; static int n; static Place[] places; static double[][] dp; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); x0 = Integer.parseInt(first[0]); y0 = Integer.parseInt(first[1]); n = Integer.parseInt(br.readLine()); places = new Place[n]; for (int i = 0; i < n; i++) { places[i] = new Place(br.readLine().split(" ", 3)); } dp = new double[1 << n][n + 1]; System.out.println(dfw((1 << n) - 1, n, x0, y0)); } static double dfw(int key, int idx, int x, int y) { if (key == 0) { return (Math.abs(x - x0) + Math.abs(y - y0)) * 100.0 / 120.0; } if (dp[key][idx] != 0.0) { return dp[key][idx]; } double total = 0; for (int i = 0; i < n; i++) { if (((1 << i) & key) != 0) { total += places[i].weight; } } double min = Double.MAX_VALUE; for (int i = 0; i < n; i++) { if (((1 << i) & key) != 0) { double time = (Math.abs(x - places[i].x) + Math.abs(y - places[i].y)) * (total + 100.0) / 120.0 + places[i].weight; min = Math.min(min, dfw(key ^ (1 << i), i, places[i].x, places[i].y) + time); } } dp[key][idx] = min; return min; } static class Place { int x; int y; double weight; public Place(String[] args) { x = Integer.parseInt(args[0]); y = Integer.parseInt(args[1]); weight = Double.parseDouble(args[2]); } } }