#include <bits/stdc++.h>
using namespace std;
struct Point {
  double a, b;
  Point() {
    a = 0;
    b = 0;
  }
  Point(double _a, double _b) {
    a = _a;
    b = _b;
  }
  bool db(Point t) { return abs(t.a * b - t.b * a) < 1e-5; }
};
class Line {
 public:
  double a, b, c;
  Line() {
    a = 1;
    b = 0;
    c = 0;
  }
  Line(double _a, double _b, double _c) {
    a = _a;
    b = _b;
    c = _c;
  }
  Line(Line t, Point x) {
    a = t.b;
    b = -t.a;
    c = -x.a * a - x.b * b;
  }
  void read() { scanf("%lf%lf%lf", &a, &b, &c); }
  Point cz() { return Point(b * c / (a * a + b * b), a * c / (a * a + b * b)); }
};
Line x;
Point w[3003];
int n, y, z;
double v[3003];
long long ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    x.read();
    w[i] = x.cz();
  }
  ans = 0;
  for (int i = 1; i <= n - 2; i++) {
    y = 0;
    int sum = 0;
    for (int j = i + 1; j <= n; j++) {
      if (abs(w[i].a - w[j].a) < 1e-12 && abs(w[i].b - w[j].b) < 1e-12)
        sum++;
      else if (abs(w[i].b - w[j].b) < 1e-12)
        v[++y] = 1e100;
      else
        v[++y] = (w[j].a - w[i].a) / (w[j].b - w[i].b);
    }
    for (int j = 1; j <= sum; j++) ans += n - i - j;
    sort(v + 1, v + y + 1);
    z = 0;
    for (int j = 2; j <= y; j++) {
      if (abs(v[j] - v[j - 1]) < 1e-12) {
        z++;
      } else {
        z = 0;
      }
      ans += z;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
