#include <iostream>
#include <algorithm>
#include <complex>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
using namespace std;

#define EPS (1e-10)

typedef complex<double> P;
typedef pair<double,double> PD;

const pair<P,P> INF = (make_pair(P(999999, 999999), P(999999, 999999)));
const pair<P,P> MINF = (make_pair(P(-999999, -999999), P(-999999, -999999)));
const double PI = acos(-1);

int N;
P T[102];
double R[102];

bool eqP(P a, P b){
  return
    abs(a.real() - b.real()) < EPS &&
    abs(a.imag() - b.imag()) < EPS;
}

bool isnanP(P p){
  return isnan(p.real()) || isnan(p.imag());
}

// テ・ツ??」ツ?ィテ・ツ??」ツ?ョテ、ツコツ、テァツつケ
pair<P,P> pointCC(P a, double r1, P b, double r2){
  double d = abs(b - a);
 
  if(d + EPS > r1 + r2 && abs(d - r1 - r2) > EPS){
    return INF;
  }

  double x = (d * d + r1 * r1 - r2 * r2) / (d * 2);
  P e = (b - a) / d;
  P f = e * P(0, 1) * sqrt(max(r1 * r1 - x * x , 0.0));

  if(isnanP(a + e * x - f) || isnanP(a + e * x + f)){
    if(r1 > r2) return INF;
    else        return MINF;
  }
  return make_pair(a + e * x - f , a + e * x + f);
}

void show(pair<P,P> pir){
  cout << pir.first << ", " << pir.second << endl;
}

double dot(const P& a, const P& b){
  return real(conj(a) * b);
}

double getAngle(const P &a, const P &b){
  return acos(dot(a, b) / abs(a) / abs(b));
}

P rotate(P a, double rad){
  double nx = a.real() * cos(rad) - a.imag() * sin(rad);
  double ny = a.real() * sin(rad) + a.imag() * cos(rad);
  return P(nx, ny);
}

bool containsCP(const P &o, const double &r, const P &p){
  double dist = abs(p - o);
  return dist < r + EPS;
}

void solve(){
  double ans = 0.0;

  for(int i = 0; i < N; i++){
    ans += 2 * R[i] * PI;
  }

  for(int i = 0; i < N; i++){
    vector<PD> v;
    bool flg = true;

    for(int j = 0; j < N; j++){
      if(i == j) continue;

      pair<P,P> cr = pointCC(T[i], R[i], T[j], R[j]);

      if(cr == INF) continue;
      if(cr == MINF){
        flg = false;
        ans -= R[i] * 2 * PI;
        break;
      }

      if(eqP(cr.first, cr.second)){
        if(abs(T[i] - T[j]) < R[i] + R[j] && abs(cr.first - T[i]) < abs(cr.first - T[j])){
          flg = false;
          ans -= R[i] * 2 * PI;
          break;
        }
        else{
          continue;
        }
      }

      double theta1 = atan2(cr.first.imag() - T[i].imag(), cr.first.real() - T[i].real());
      double theta2 = atan2(cr.second.imag() - T[i].imag(), cr.second.real() - T[i].real());

      if(theta1 > theta2){
        swap(theta1, theta2);
        swap(cr.first, cr.second);
      }

      if(containsCP(T[j], R[j], T[i] + rotate(cr.first - T[i], 100 * EPS))){
        v.push_back(PD(theta1, theta2));
      }
      else{
        v.push_back(PD(-PI, theta1));
        v.push_back(PD(theta2, PI));
      }
    }

    if(!flg) continue;

    sort(v.begin(), v.end());

    double sum = R[i] * 2 * PI;
    double before = -PI;

    for(int j = 0; j < v.size(); j++){
      double from = max(before, v[j].first);
      double to = v[j].second;
      if(from > to) continue;
      before = max(before, to);
      ans -= R[i] * (to - from);

      sum -= R[i] * (to - from);
    }
  }

  cout << fixed << setprecision(12) << abs(ans) << endl;
}

int main(){
  while(cin >> N, N){
    for(int i = 0; i < N; i++){
      cin >> T[i].real() >> T[i].imag() >> R[i];
    }
    solve();
  }
}

Measured memory_bytes: 1372