from math import sqrt class UnionFind(object): def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x != y: if self.rank[x] < self.rank[y]: x, y = y, x if self.rank[x] == self.rank[y]: self.rank[x] += 1 self.par[y] = x self.size[x] += self.size[y] def is_same(self, x, y): return self.find(x) == self.find(y) def get_size(self, x): x = self.find(x) return self.size[x] def dist1(i, j): return (X[i] - X[j]) ** 2 + (Y[i] - Y[j]) ** 2 def dist2(i, j): return abs(sqrt(X[i] ** 2 + Y[i] ** 2) - sqrt(X[j] ** 2 + Y[j] ** 2)) N = int(input()) X, Y, T = [0] * N, [0] * N, [0] * N for i in range(N): X[i], Y[i], T[i] = map(int, input().split()) yes = 10 ** 18 + 5 no = -1 eps = 10**-10 while yes - no != 1: mid = (yes + no)//2 U = UnionFind(N) for i in range(N): for j in range(i + 1, N): if T[i] != T[j]: if dist2(i, j) ** 2 - eps <= mid: U.union(i, j) else: if dist1(i, j) <= mid: U.union(i, j) if U.is_same(0, N - 1): yes = mid else: no = mid print(yes)