import sys input = sys.stdin.readline from math import sqrt N=int(input()) P=[list(map(int,input().split())) for i in range(N)] OK=3200000000 NG=-1 eps=10**(-10) while OK>NG+1: mid=(OK+NG)//2 CAN=[0]*N CAN[0]=1 Q=[0] while Q: x=Q.pop() x0,y0,t0=P[x] for i in range(N): if CAN[i]==1: continue x1,y1,t1=P[i] if t0==t1: dis=(x0-x1)**2+(y0-y1)**2 if dis<=mid: CAN[i]=1 Q.append(i) else: dis=(sqrt(x1*x1+y1*y1)-sqrt(x0*x0+y0*y0))**2 if dis<=mid+eps: CAN[i]=1 Q.append(i) if CAN[N-1]==1: OK=mid else: NG=mid print(OK)