#include <bits/stdc++.h>
using namespace std;
struct point {
  double x, y;
  point() {}
  point(double xx, double yy) {
    x = xx;
    y = yy;
  }
};
struct line {
  double a, b, c;
  line() {}
  line(double aa, double bb, double cc) {
    a = aa;
    b = bb;
    c = cc;
  }
};
int n, i, j, ii, jj, xx, yy, zz, kl, sum, gr;
point p[101][5], q[1000], tt;
int kol[101][4], num[1000], who[1000];
line ll[101][4];
bool u[101];
double eps, ans;
point operator-(point p1, point p2) { return point(p1.x - p2.x, p1.y - p2.y); }
line pr2t(point p1, point p2) {
  return line(p2.y - p1.y, p1.x - p2.x,
              p1.x * (p1.y - p2.y) + p1.y * (p2.x - p1.x));
}
bool peresekpr(line l1, line l2) {
  if (fabs(l1.a * l2.b - l2.a * l1.b) < eps)
    return false;
  else
    return true;
}
point tperpr(line l1, line l2) {
  return point((l1.b * l2.c - l1.c * l2.b) / (l1.a * l2.b - l1.b * l2.a),
               (l1.a * l2.c - l1.c * l2.a) / (l1.b * l2.a - l1.a * l2.b));
}
bool eq(point p1, point p2) {
  if ((fabs(p1.x - p2.x) < eps) && (fabs(p1.y - p2.y) < eps))
    return true;
  else
    return false;
}
double skal(point p1, point p2) { return p1.x * p2.x + p1.y * p2.y; }
double vect(point p1, point p2) { return p1.x * p2.y - p1.y * p2.x; }
double len(point p) { return sqrt(p.x * p.x + p.y * p.y); }
bool printotr(point p, point p1, point p2) {
  if ((eq(p, p1)) || (eq(p, p2)))
    return false;
  else if ((fabs(vect(p2 - p1, p - p1)) < eps) && (skal(p1 - p, p2 - p) < 0))
    return true;
  else
    return false;
}
bool men(int i, int j) {
  double zz = q[i].x - q[j].x;
  if (zz < -eps)
    return true;
  else if (zz > eps)
    return false;
  else
    return (q[i].y - q[j].y < -eps);
}
int main() {
  scanf("%d", &n);
  eps = 1e-4;
  for (i = 1; i <= n; i++) {
    for (ii = 1; ii <= 3; ii++) {
      scanf("%d%d", &xx, &yy);
      p[i][ii] = point(xx, yy);
    }
    p[i][4] = p[i][1];
    for (ii = 1; ii <= 3; ii++) {
      ll[i][ii] = pr2t(p[i][ii], p[i][ii + 1]);
      zz = ii + 2;
      if (zz > 3) zz -= 3;
    }
  }
  for (i = 1; i <= n; i++) {
    for (ii = 1; ii <= 3; ii++) {
      kl = 2;
      q[1] = p[i][ii];
      q[2] = p[i][ii + 1];
      num[1] = 1;
      num[2] = 2;
      for (j = 1; j <= n; j++) {
        if (i == j) continue;
        zz = 0;
        for (jj = 1; jj <= 3; jj++) {
          if (!peresekpr(ll[i][ii], ll[j][jj])) continue;
          tt = tperpr(ll[i][ii], ll[j][jj]);
          if (printotr(tt, p[j][jj], p[j][jj + 1])) {
            kl++;
            q[kl] = tt;
            num[kl] = kl;
            who[kl] = j;
            zz++;
          }
        }
        if (zz == 1) {
          for (jj = 1; jj <= 3; jj++) {
            if (!peresekpr(ll[i][ii], ll[j][jj])) continue;
            tt = tperpr(ll[i][ii], ll[j][jj]);
            if ((eq(tt, p[j][jj])) || (eq(tt, p[j][jj + 1]))) {
              kl++;
              q[kl] = tt;
              num[kl] = kl;
              who[kl] = j;
              break;
            }
          }
        }
      }
      sort(num + 1, num + kl + 1, men);
      for (j = 1; j <= n; j++) u[j] = 0;
      sum = 0;
      gr = 0;
      for (j = 1; j <= kl; j++) {
        jj = num[j];
        if ((jj == 1) || (jj == 2)) {
          gr++;
          if (gr == 2) {
            if (sum == 0) ans += len(q[jj] - q[num[j - 1]]);
            break;
          }
          if (gr == 1) continue;
        }
        if (u[who[jj]]) {
          sum--;
        } else {
          sum++;
          u[who[jj]] = true;
          if ((gr > 0) && (j > 1) && (sum == 1))
            ans += len(q[jj] - q[num[j - 1]]);
        }
      }
    }
  }
  cout.precision(30);
  cout << ans;
  return 0;
}
