#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
struct line {
  double k, b;
  inline bool operator<(const line t) const {
    if (fabs(k - t.k) > eps)
      return k < t.k;
    else
      return b < t.b;
  }
};
line l[5000000];
double px[3000], py[3000];
int i, j, k, n, t, x, y, z;
long long s;
bool b;
inline void calc(int x) {
  for (int i = 1;; i++)
    if (i * (i - 1) / 2 == x) {
      s = s + 1LL * i * (i - 1) * (i - 2) / 6;
      return;
    }
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d%d", &x, &y, &z);
    px[i] = -1.0 * x * z / (x * x + y * y);
    py[i] = -1.0 * y * z / (x * x + y * y);
    if (fabs(px[i]) + fabs(py[i]) < eps)
      if (!b)
        b = true;
      else
        s = s + n - 2, i--, n--;
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j < i; j++)
      if (fabs(px[i] - px[j]) < eps)
        k++, l[k] = (line){-1e10, px[i]};
      else
        k++, l[k].k = 1.0 * (py[i] - py[j]) / (px[i] - px[j]),
             l[k].b = py[i] - l[k].k * px[i];
  sort(l + 1, l + k + 1);
  l[k + 1].k = 1e10;
  for (i = 1; i <= k + 1; i++)
    if ((fabs(l[i].k - l[i - 1].k) < eps) && (fabs(l[i].b - l[i - 1].b) < eps))
      t++;
    else
      calc(t), t = 1;
  calc(t);
  printf("%I64d", s);
  return 0;
}
