Problem: A crop circle suddenly appeared on the vast agricultural land of Argentina. A total of n crop circles were confirmed, including overlapping, popping, large, and small ones.

When a mystery hunter tried to capture the whole picture of a crop circle from the air, he found it difficult to show the beautiful pattern in the image because the outline of each circle was not clear.

Therefore, the mystery hunter proposed to emphasize the contour by installing a string of special material along the contour.

The part where the string is installed is the part on the circumference of one crop circle that is not included in any other crop circle.

The film crew asked you to create a program to measure the required string length. Enter the center coordinates and radius of each crop circle and create a program to report the length of the string to be installed.

For reference, the first and second cases of the input / output examples are shown in FIGS. 1 and 2, respectively. The part of the string is shown by a thick line.


<image>


Figure 1



<image>


Figure 2



Constraints

* n ≤ 100
* -1000 ≤ xi, yi ≤ 1000
* 0 <ri ≤ 100

Input

Multiple datasets are given as input. Each dataset is given in the following format:

n (number of crop circles: integer)
x1 y1 r1 (center coordinates and radius of the first circle: real numbers separated by blanks)
x2 y2 r2 (center coordinates and radius of the second circle: real numbers separated by blanks)
..
..
xn yn rn (center coordinates and radius of the nth circle: real numbers separated by blanks)


When n is 0, it indicates the end of input.

Output

Output the string length on one line for each dataset. The output may contain an error of 0.000001 or less.

Example

Input

4
6 4 2
4 7 3
7 10 3
13 6 1
4
7 4 2
4 7 3
7 10 3
11 6 3
0


Output

39.664699289572
45.627024663706

Solution (in CPP):

Solution:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;

bool eq(ld a, ld b) {
	return (abs(a - b) < eps);
}

class Line {
public:
	Point a, b;
};
class Circle {
public:
	Point p; ld r;
};

ld dot(Point a, Point b) {
	return real(conj(a)*b);
}
ld cross(Point a, Point b) {
	return imag(conj(a)*b);
}
Point proj(Line l, Point p) {
	ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
	return l.a + t * (l.a - l.b);
}
ld dist_lp(Line l, Point p) {
	return abs(p - proj(l, p));
}

int ccw(Point a, Point b, Point c) {
	b -= a; c -= a;
	if (cross(b, c) > eps)return 1;//a,b,cが反時計回り
	if (cross(b, c) < -eps)return -1;//a,b,cが時計回り
	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の順に一直線
}
bool isis_ll(Line l, Line m) {
	return !eq(cross(l.b - l.a, m.b - m.a), 0);
}
Point is_ll(Line s, Line t) {
	Point sv = s.b - s.a; Point tv = t.b - t.a;
	return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

//counterclockwise
struct polygon {
private:
	vector<Point> p;
public:
	polygon(vector<Point> &v) {
		p = v;
	}
	//f=true:left-side
	void convex_cut(Line &l) {
		vector<Point> nex;
		rep(i, p.size()) {
			Point a = p[i], b = p[(i + 1) % p.size()];
			if (ccw(l.a, l.b, a) != -1)nex.push_back(a);
			if (ccw(l.a,l.b,a)*ccw(l.a,l.b,b)<0) {
				nex.push_back(is_ll({ a,b }, l));
			}
		}
		p = nex;
	}
	bool query() {
		return p.size();
	}
};

vector<Point> is_cc(Circle c1, Circle c2) {
	vector<Point> res;
	ld d = abs(c1.p - c2.p);
	ld rc = (d*d + c1.r*c1.r - c2.r*c2.r) / (2 * d);
	ld dfr = c1.r*c1.r - rc * rc;
	if (abs(dfr) < eps)dfr = 0.0;
	if (dfr < 0.0)return res;
	ld rs = sqrt(dfr);
	Point diff = (c2.p - c1.p) / d;
	res.push_back(c1.p + diff * Point(rc, rs));
	if (dfr != 0.0)res.push_back(c1.p + diff * Point(rc, -rs));
	return res;
}
bool in_Circle(Circle a, Circle b) {
	ld dist = abs(b.p - a.p);
	return dist < b.r - a.r+eps;
}
ld calc_angle(Circle &c, Point &p) {
	Point u = p - c.p;
	return atan2(imag(u), real(u));
}
int n;
void solve() {
	vector<Circle> c(n);
	rep(i, n) {
		ld x, y, r; cin >> x >> y >> r;
		c[i] = { {x,y},r };
	}
	ld ans = 0;
	rep(i, n) {
		//cout << i << endl;
		bool f = true;
		vector<pair<ld,int>> v;
		int cnt = 0;
		rep(j, n) {
			if (i == j)continue;
			if (in_Circle(c[i], c[j])) {
				f = false; break;
			}
			vector<Point> sc = is_cc(c[i], c[j]);
			if (sc.size() == 2) {
				ld t1 = calc_angle(c[i], sc[0]);
				ld t2 = calc_angle(c[i], sc[1]);
				v.push_back({ t1,0 });
				v.push_back({ t2,1 });
				if (t1 < t2)cnt++;
				//cout << t2 << " " << t1 << endl;
			}
		}
		if (f) {
			ld cur = -pi;
			sort(v.begin(), v.end());
			ld csum = 0;
			rep(i, v.size()) {
				//cout << v[i].first << endl;
				if (cnt > 0) {
					csum += v[i].first - cur;
				}
				if (v[i].second)cnt++;
				else cnt--;
				cur = v[i].first;
			}
			if (cnt > 0)csum += pi - cur;
			ans += c[i].r*(2*pi - csum);
			//cout << csum << endl;
			//cout << c[i].r*(2 * pi - csum) << endl;
		}
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(9);
	while (cin >> n, n) {
		solve();
	}
	//solve();
	//stop
	return 0;
}