EPS = 1e-8
X, Y, L = 0, 1, 2

class Point
  include Comparable
  attr_accessor :x, :y
  def initialize(x=0.0, y=0.0)
    @x, @y = x.to_f, y.to_f
  end
  def <=>(p)
    @x != p.x ? @x <=> p.x : @y <=> p.y
  end
  def +(p)
    Point.new(@x+p.x, @y+p.y)
  end
  def -(p)
    Point.new(@x-p.x, @y-p.y)
  end
  def -@
    Point.new(-@x, -@y)
  end
  def times(f)
    Point.new(@x*f, @y*f)
  end
  def dot(p)
    @x*p.x + @y*p.y
  end
  def cross(p)
    @x*p.y - @y*p.x
  end
  def abs
    Math::hypot(@x, @y)
  end
  def norm
    @x**2 + @y**2
  end
end

class Circle
  include Comparable
  attr_accessor :x, :y, :r
  def initialize(x=0.0, y=0.0, r=1.0)
    @x, @y, @r = x.to_f, y.to_f, r.to_f
  end
  def <=>(c)
    @x!=c.x ? @x<=>c.x : (@y!=c.y ? @y<=>c.y : @r<=>c.r)
  end
  def point
    Point.new(@x, @y)
  end
  def distance(c)
    (point-c.point).abs
  end
  def include?(p)
    (point-p).abs <= @r
  end
  def in?(c)
    distance(c) < (@r-c.r).abs
  end
  def touch?(c)
    distance(c) <= @r + c.r
  end
  def crossPoint(c)
    angle = Math::atan2(c.y-@y, c.x-@x)
    d = distance(c)
    add = Math::acos((d**2 + @r**2 - c.r**2) / (2.0*d*@r))
    p1 = Point.new(@x+@r*Math::cos(angle+add), @y+@r*Math::sin(angle+add))
    p2 = Point.new(@x+@r*Math::cos(angle-add), @y+@r*Math::sin(angle-add))
    [p1, p2]
  end
end

def check(height)
  result = false
  circle = Array.new
  @rope.each do |rope|
    return false if rope[L] < height
    circle.push(Circle.new(rope[X], rope[Y], Math::sqrt(rope[L]**2-height**2)))
  end
  crossPoint = Array.new
  circle.each do |c1|
    crossPoint.push(c1.point)
    circle.each do |c2|
      next if c1 == c2
      next if c1.in?(c2)
      next unless c1.touch?(c2)
      crossPoint.push(*c1.crossPoint(c2))
    end
  end
  crossPoint.each do |p|
    ok = true
    circle.each do |c|
      ok = false unless c.include?(p)
    end
    result = true if ok
  end
  result
end

until (@n=gets.to_i).zero?
  @rope = Array.new
  @n.times {@rope.push(gets.split.map(&:to_f))}
  mid = 0.0
  low = 0.0
  high = 300.0
  until high-low < EPS
    mid = (high+low) / 2.0
    case check(mid)
      when true
        low = mid
        answer = mid
      when false
        high = mid
    end
  end
  p mid
end