import sys import random import time import math from a import TSP from kmeans import KmeansPlusPlus N, M = map(int, input().split()) AB = [tuple(map(int, input().split())) for _ in range(N)] kmeans = KmeansPlusPlus(M) labels, cluster_centers = kmeans.fit(AB) obj = AB + cluster_centers dist = [[0]*(N+M) for _ in range(N+M)] for i in range(N+M): for j in range(N+M): d = (obj[i][0] - obj[j][0])**2 + (obj[i][1] - obj[j][1])**2 if i < N: d *= 5 if j < N: d *= 5 dist[i][j] = 5 tsp = TSP(obj) path, score, loops = tsp.solve() print(score, file=sys.stderr) for c,d in cluster_centers: print(c, d) print(len(path)) for p in path: if p < N: print(1, p+1) else: print(2, p-N+1)