#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

constexpr double EPS = 1e-9;
constexpr int INF = 1000000;

struct point {
	double x, y;
	explicit point(double x = 0.0, double y = 0.0):x(x), y(y) {}
	point(const point& p):x(p.x), y(p.y) {}

	point operator+ (const point &p) const {
		return point(x + p.x, y + p.y);
	}

	point operator- (const point &p) const {
		return point(x - p.x, y - p.y);
	}

	point operator* (const double s) const {
		return point(x * s, y * s);
	}

	point operator* (const point &p) const {
		return point(x * p.x - y * p.y, x * p.y + y * p.x);
	}

	point operator/ (const double s) const {
		return point(x / s, y / s);
	}

	bool operator< (const point &p) const {
		return x + EPS < p.x || abs(x - p.x) < EPS && y + EPS < p.y;
	}

	bool operator== (const point &p) const {
		return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
	}
};

inline double norm(const point &p) {
	return p.x * p.x + p.y * p.y;
}

inline double abs(const point &p) {
	return sqrt(norm(p));
}

inline double dot(const point &a, const point &b) {
	return a.x * b.x + a.y * b.y;
}

inline double cross(const point &a, const point &b) {
	return a.x * b.y - a.y * b.x;
}

struct segment {
	point a, b;
	segment(const point &a, const point &b):a(a), b(b){}
};

struct circle {
	point c;
	double r;
	circle(const point &c, double r):c(c), r(r){}
};

inline int ccw(const point& a, point b, point c) {
	b = b - a;
	c = c - a;
	const double t = cross(b, c);
	if(t > EPS) return 1; // ccw
	if(t < -EPS) return -1; // cw
	if(dot(b, c) < 0) return 2; // c, a, b ???????????´??????
	if(norm(b) < norm(c)) return -2; // a, b, c ???????????´??????
	return 0; //a, c, b ?????§?????´??????
}

inline bool intersect(const segment& s, const segment& t) {
	return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
		ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

inline bool intersect(const segment& s, const point& p) {
	return ccw(s.a, s.b, p) == 0;
}

inline bool intersect(const circle& c, const circle& d) {
	return abs(c.c - d.c) <= c.r + d.r && abs(c.c - d.c) >= abs(c.r - d.r);
}

inline point crosspoint(const segment& s, const segment& t) {
	if(!intersect(s, t)) return point(INF, INF); // ?????????????????????

	const double tmp = cross(s.b - s.a, t.b - t.a);
	if(abs(tmp) < EPS) { // ?????´??????
		if(intersect(s, t.a)) return t.a;
		if(intersect(s, t.b)) return t.b;
		if(intersect(t, s.a)) return s.a;
		return s.b;
	}

	return t.a + (t.b - t.a) * cross(s.b - s.a, s.b - t.a) * (1.0 / tmp);
}

inline vector<point> crosspoint(const circle &c, const circle& d) {
	vector<point> res;
	if(abs(c.c - d.c) < EPS) return res; // ???????????§?¨??????????

	const double tmp = abs(c.c - d.c);
	const double rc = (tmp * tmp + c.r * c.r - d.r * d.r) / (tmp + tmp);
	const double rs = sqrt(c.r * c.r - rc * rc);
	const point diff = (d.c - c.c) / tmp;
	res.push_back(point(c.c + diff * point(rc, rs)));
	res.push_back(point(c.c + diff * point(rc, -rs)));
	return res;
}

int main() {
	for(int n; scanf("%d", &n), n;) {
		vector<circle> cs;
		cs.reserve(n);
		vector<point> candidates;
		candidates.reserve(n * n * n * n);

		for(int i = 0; i < n; ++i) {
			int x, y, l;
			scanf("%d %d %d", &x, &y, &l);
			cs.emplace_back(point(x, y), l);
			candidates.emplace_back(cs[i].c);
		}

		vector<segment> segs;
		segs.reserve(n * n);
		for(int i = 0; i < n; ++i) {
			for(int j = i + 1; j < n; ++j) {
				if(!intersect(cs[i], cs[j])) continue;

				const vector<point> ps = crosspoint(cs[i], cs[j]);
				candidates.emplace_back((ps[0] + ps[1]) / 2.0);
				segs.emplace_back(ps[0], ps[1]);
			}
		}

		const int m = segs.size();
		for(int i = 0; i < m; ++i) {
			for(int j = i + 1; j < m; ++j) {
				const point p = crosspoint(segs[i], segs[j]);
				if(p.x < INF) candidates.emplace_back(p);
			}
		}

		double ans = 1.0;
		for(const auto &p : candidates) {
			double mn = INF;
			for(int j = 0; j < n; ++j) {
				chmin(mn, cs[j].r * cs[j].r - norm(cs[j].c - p));
			}
			chmax(ans, mn);
		}

		printf("%.7lf\n", sqrt(ans));
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1100