import functools line = input().split() X0 = int(line[0]) Y0 = int(line[1]) N = int(input()) X = [] Y = [] W = [] for i in range(N): line = input().split() X.append(int(line[0])) Y.append(int(line[1])) W.append(float(line[2])) sum = sum(W) u = [False for i in range(N)] def dist(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) def time(dist, weight): return dist * (weight + 100) / 120 def func(pos, weight): if pos == -1: xx = X0 yy = Y0 else: xx = X[pos] yy = Y[pos] if weight == 0: return time(dist(X0, Y0, xx, yy), 0) result = 9999999 for i in range(N): if u[i]: continue u[i] = True t = time(dist(xx, yy, X[i], Y[i]),weight) + func(i, weight - W[i]) result = min(result, t) u[i] = False return result print(func(-1, sum)+sum)