#include <bits/stdc++.h>
using namespace std;
const int N = 2333;
const double eps = 1e-12, pi = acos(-1.0), pi2 = pi * 2;
inline int sgn(double x) { return fabs(x) < eps ? 0 : x < 0 ? -1 : 1; }
struct P {
  double x, y;
  P(double x = 0.0, double y = 0.0) : x(x), y(y) {}
  P operator+(const P& o) const { return P(x + o.x, y + o.y); }
  P operator-(const P& o) const { return P(x - o.x, y - o.y); }
  P operator*(const double& k) const { return P(x * k, y * k); }
  P operator/(const double& k) const { return P(x / k, y / k); }
  double operator*(const P& o) const { return x * o.x + y * o.y; }
  double operator%(const P& o) const { return x * o.y - y * o.x; }
  double len() const { return hypot(x, y); }
  double len(const P& o) const { return hypot(x - o.x, y - o.y); }
  double len2() const { return x * x + y * y; }
  double len2(const P& o) const {
    return (x - o.x) * (x - o.x) + (y - o.y) * (y - o.y);
  }
  double angle() const { return atan2(y, x); }
  double angle(const P& center) const {
    return atan2(y - center.y, x - center.x);
  }
};
struct L {
  P a, b;
  L() {}
  L(double A, double B, double C) {
    if (sgn(A)) {
      a = P(-C / A, 0);
      b = P((-C - B) / A, 1);
    } else {
      a = P(0, -C / B);
      b = P(1, (-C - A) / B);
    }
  }
  P prog(const P& p) const {
    return a + (b - a) * (((b - a) * (p - a)) / b.len2(a));
  }
  bool read() {
    double A, B, C;
    scanf("%lf%lf%lf", &A, &B, &C);
    if (sgn(C) == 0) return false;
    *this = L(A, B, C);
    return true;
  }
};
struct CMP {
  P p;
  CMP(const P& p) : p(p) {}
  bool operator()(const P& a, const P& b) const {
    return a.angle(p) < b.angle(p);
  }
};
struct DB {
  double x;
  DB(double x) : x(x) {}
  bool operator<(const DB& o) const { return sgn(x - o.x) < 0; }
};
P p[N];
int n, m;
int main() {
  while (scanf("%d", &m) == 1) {
    L l;
    n = 0;
    long long ans = 0;
    for (int i = 0; i < m; ++i) {
      if (l.read())
        p[n++] = l.prog(P(0, 0));
      else
        ++ans;
    }
    ans = ans * (ans - 1) / 2 * n;
    for (int i = 2; i < n; ++i) {
      map<DB, int> cnt;
      for (int j = 0; j < i; ++j) {
        double ang = p[j].angle(p[i]);
        while (ang < 0) ang += pi;
        while (ang >= pi) ang -= pi;
        if (sgn(ang - pi) == 0) ang = 0.0;
        cnt[DB(ang)]++;
      }
      for (map<DB, int>::iterator it = cnt.begin(); it != cnt.end(); ++it) {
        ans += it->second * (it->second - 1) / 2;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
