def solve(): from math import sqrt,ceil N=int(input()) X=[0]*N; Y=[0]*N; T=[0]*N for i in range(N): X[i],Y[i],T[i]=map(int,input().split()) level=[[0]*N for _ in range(N)] for i in range(N): level_i=level[i] for j in range(N): if T[i]==T[j]: dx=X[i]-X[j] dy=Y[i]-Y[j] level_i[j]=dx*dx+dy*dy else: ri=sqrt(X[i]*X[i]+Y[i]*Y[i]) rj=sqrt(X[j]*X[j]+Y[j]*Y[j]) level_i[j]=ceil(abs(ri-rj)**2) inf=float("inf") D=[inf]*N; D[0]=0 F=[0]*N for _ in range(N): i=-1 for p in range(N): if F[p]==0 and (i==-1 or D[p]