from math import hypot def list3(a, b, c, *, val=0): return [[[val] * c for _ in range(b)] for _ in range(a)] def distance(a: tuple[int, int], b: tuple[int, int]) -> float: return hypot(a[0] - b[0], a[1] - b[1]) INF = 1 << 60 N, K = map(int, input().split()) houses = [] for _ in range(N): x, y = map(int, input().split()) houses.append((x, y)) dp = list3(1 << N, N, K, val=INF) # i : 訪問した頂点集合 # j : 最後に訪れた頂点 # k : 持っているピザの枚数 # ときの時間の最小値 # 初期状態 for i, (x, y) in enumerate(houses): d = distance((0, 0), (x, y)) dp[1 << i][i][K-1] = d for i in range(1 << N): # 訪れた頂点集合 for j in range(N): # 最後に訪れた頂点 if ~i & (1 << j): continue for k in range(K): # 持っているピザの枚数 if dp[i][j][k] == INF: continue for to in range(N): # 次の訪問先 if i & (1 << to): continue b = i | (1 << to) cost = distance(houses[j], houses[to]) # 直接向かう if k > 0: dp[b][to][k-1] = min(dp[b][to][k-1], dp[i][j][k] + cost) # ピザ屋に戻ってから、次の家に向かう cost2 = distance(houses[j], (0, 0)) + distance((0, 0), houses[to]) dp[b][to][K-1] = min(dp[b][to][K-1], dp[i][j][k] + cost2) ans = INF b = (1 << N) - 1 for j in range(N): for k in range(K): d = dp[b][j][k] + distance(houses[j], (0, 0)) ans = min(ans, d) print(ans)