import collections def read_data(): x0, y0 = map(int, input().split()) N = int(input()) XY = [(0, 0)] W = [0.0] for i in range(N): x, y, w = input().split() XY.append((int(x) - x0, int(y) - y0)) W.append(float(w)) return N, XY, W def solve(N, XY, W): global record T, N, XY, W = simplify(N, XY, W) dist = [[abs(xi - xj) + abs(yi - yj) for (xj, yj) in XY] for (xi, yi) in XY] used = [False] * N used[0] = True n_used = 1 pos = 0 cum_d = 0 cum_t = 0 record = float('inf') time = T + dfs(N, W, dist, cum_d, cum_t, pos, used, n_used) / 120.0 return time def simplify(N, XY, W): pos_w = collections.defaultdict(int) for (x, y), w in zip(XY, W): pos_w[x, y] += w newXY = [(0, 0)] newW = [0] del pos_w[0, 0] for (x, y), w in pos_w.items(): newXY.append((x, y)) newW.append(w) return sum(W), len(newW), newXY, newW def dfs(N, W, dist, cum_d, cum_t, pos, used, n_used): global record if n_used == N: cum_t += (cum_d + dist[pos][0]) * 100 if cum_t < record: record = cum_t return record best_time = float('inf') dpos = dist[pos] for new_pos, is_used in enumerate(used): if is_used: continue new_cum_d = cum_d + dpos[new_pos] new_cum_t = cum_t + new_cum_d * W[new_pos] if new_cum_t >= record: continue used[new_pos] = True time = dfs(N, W, dist, new_cum_d, new_cum_t, new_pos, used, n_used + 1) if best_time > time: best_time = time used[new_pos] = False return best_time N, XY, W = read_data() print(solve(N, XY, W))