#include <bits/stdc++.h>
using namespace std;
long double cross(complex<long double> p, complex<long double> q) {
  return imag(conj(p) * q);
}
int dir(complex<long double> a, complex<long double> b,
        complex<long double> c) {
  complex<long double> u = b - a;
  complex<long double> v = c - a;
  long double x = cross(u, v);
  return (((x) > 0) - ((x) < 0));
}
bool inside(complex<long double> a, complex<long double> b,
            complex<long double> c, complex<long double> x) {
  int u = dir(a, b, x);
  int v = dir(b, c, x);
  int w = dir(c, a, x);
  return u * v >= 0 && u * w >= 0 && v * w >= 0;
}
bool lineline(complex<long double> a1, complex<long double> a2,
              complex<long double> b1, complex<long double> b2,
              complex<long double> &isect, long double *at = 0,
              long double *bt = 0) {
  long double d = cross(a2 - a1, b2 - b1);
  if (d == 0) return false;
  long double t = cross(b2 - b1, a1 - b1) / d;
  long double s = cross(a2 - a1, a1 - b1) / d;
  if (t < 0 || t > 1) return false;
  if (s < 0 || s > 1) return false;
  isect = a1 + (a2 - a1) * t;
  if (at) *at = t;
  if (bt) *bt = s;
  return true;
}
complex<long double> P[120][3];
long double solve(complex<long double> a, complex<long double> b, int me,
                  int N) {
  vector<pair<long double, long double> > I;
  for (int i = 0; i < (N); ++i) {
    if (i == me) continue;
    if (inside(P[i][0], P[i][1], P[i][2], a) &&
        inside(P[i][0], P[i][1], P[i][2], b))
      return 0;
    int d1 = dir(a, b, P[i][0]);
    int d2 = dir(a, b, P[i][1]);
    int d3 = dir(a, b, P[i][2]);
    if (d1 * d2 >= 0 && d2 * d3 >= 0 && d1 * d3 >= 0) continue;
    for (int j = 0; j < (3); ++j) {
    }
    vector<long double> found;
    long double t, s;
    complex<long double> tmp;
    for (int j = 0; j < (3); ++j) {
      complex<long double> u = P[i][j];
      complex<long double> v = P[i][(j + 1) % 3];
      if (lineline(a, b, u, v, tmp, &t, &s)) {
        found.push_back(t);
      }
    }
    if (found.empty()) continue;
    assert(found.size() <= 3);
    sort(found.begin(), found.end());
    if (found.size() >= 2 && abs(found[0] - found[1]) <= 1e-6) {
      swap(found[1], found.back());
      found.pop_back();
    }
    if (found.size() >= 3 && abs(found[1] - found[2]) <= 1e-6) {
      found.pop_back();
    }
    assert(!found.empty());
    assert(found.size() <= 2);
    if (found.size() == 2) {
      I.push_back(make_pair(found[0], found[1]));
    } else if (inside(P[i][0], P[i][1], P[i][2], a)) {
      I.push_back(make_pair(0, found[0]));
    } else if (inside(P[i][0], P[i][1], P[i][2], b)) {
      I.push_back(make_pair(found[0], 1));
    } else {
      assert(false);
    }
  }
  I.push_back(make_pair(1e9, 1e9));
  sort(I.begin(), I.end());
  long double ans = 0;
  long double L = 0;
  long double R = 0;
  int M = I.size();
  for (int x = 0; x < (M); ++x) {
    assert(I[x].first <= I[x].second);
    if (I[x].first <= R)
      R = max(R, I[x].second);
    else {
      assert(R >= L);
      ans += R - L;
      L = I[x].first;
      R = I[x].second;
    }
    assert(ans <= 1 + 1e-6);
  }
  return (1 - ans) * abs(b - a);
}
int main() {
  int N, a, b, c, d, e, f;
  scanf("%d", &N);
  for (int i = 0; i < (N); ++i) {
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
    P[i][0] = complex<long double>(a, b);
    P[i][1] = complex<long double>(c, d);
    P[i][2] = complex<long double>(e, f);
  }
  long double ans = 0;
  for (int i = 0; i < (N); ++i)
    for (int j = 0; j < (3); ++j)
      ans += solve(P[i][j], P[i][(j + 1) % 3], i, N);
  cout << fixed << setprecision(12) << ans << endl;
}
