#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
double x[10], y[10], l[10];

double search(double X, double Y){
	double res = 1e+9;
	for(int i = 0; i < n; i++){
		double h = l[i] * l[i] - ((X - x[i]) * (X - x[i])) - ((Y - y[i]) * (Y - y[i]));
		res = min(res, h);
	}
	return res;
}

double searchY(double X){
	double left = -100.0, right = 100.0;
	for(int i = 0; i < 200; i++){
		double mid1 = (2 * left + right) / 3;
		double mid2 = (left + 2 * right) / 3;
		if( search(X, mid1) > search(X, mid2) ){
			right = mid2;
		}else{
			left = mid1;
		}
	}
	return search(X, left);
}

double searchXY(double left = -100.0, double right = 100.0){
	for(int i = 0; i < 200; i++){
		double mid1 = (2 * left + right) / 3;
		double mid2 = (left + 2 * right) / 3;
		if( searchY(mid1) > searchY(mid2) ){
			right = mid2;
		}else{
			left = mid1;
		}
	}
	return searchY(left);
}

int main(){
	while( cin >> n , n ){
		for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> l[i];
		double ans = sqrt(searchXY());
		printf("%.07f\n", ans);
	}
}