### constant

INF = Float::INFINITY
DELTA = 1e-12

MIN_X = MIN_Y = -100.0
MAX_X = MAX_Y =  100.0

### subroutines

def min_z2(x, y)
  mz2 = INF
  $rps.each do |xi, yi, li2|
    z2 = li2 - (x - xi) ** 2 - (y - yi) ** 2
    mz2 = z2 if mz2 > z2
  end
  mz2
end

def rec_y(x)
  min_y = MIN_Y
  max_y = MAX_Y
  while (max_y - min_y > DELTA)
    y0 = (min_y * 2 + max_y) / 3
    y1 = (min_y + 2 * max_y) / 3
    mz20 = min_z2(x, y0)
    mz21 = min_z2(x, y1)
    if mz20 > mz21
      max_y = y1
    else
      min_y = y0
    end
  end
  min_z2(x, (min_y + max_y) / 2)
end

def rec_xy()
  min_x = MIN_X
  max_x = MAX_X
  while (max_x - min_x > DELTA)
    x0 = (min_x * 2 + max_x) / 3
    x1 = (min_x + 2 * max_x) / 3
    mz20 = rec_y(x0)
    mz21 = rec_y(x1)
    if mz20 > mz21
      max_x = x1
    else
      min_x = x0
    end
  end
  rec_y((x0 + x1) / 2)
end

### main

loop do 
  n = gets.to_i
  break if n == 0

  $rps = []
  n.times do
    xi, yi, li = gets.split.map(&:to_f)
    $rps << [xi, yi, li * li]
  end    
  #p $rps

  puts "%.7f" % Math.sqrt(rec_xy)
end