#include <bits/stdc++.h>
using namespace std;
int n, zero;
bool ze[2015];
double a, b, c, x[2015], y[2015];
vector<double> g;
long long ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf%lf%lf", &a, &b, &c);
    if (fabs(c) < (1e-12)) {
      zero++, ze[i] = 1;
      continue;
    }
    if (a != 0) {
      x[i] = c / (a + b * b / a);
      y[i] = b / a * x[i];
    } else {
      x[i] = 0;
      y[i] = c / b;
    }
  }
  for (int i = 1; i <= n; i++)
    if (!ze[i]) {
      g.clear();
      for (int j = 1; j <= n; j++)
        if (j != i && !ze[j]) {
          double xx = x[j] - x[i], yy = y[j] - y[i];
          if (yy < (1e-12)) xx = -xx, yy = -yy;
          if (fabs(yy) < (1e-12)) yy = fabs(yy), xx = fabs(xx);
          g.push_back(atan2(yy, xx));
        }
      sort(g.begin(), g.end());
      int now = 1;
      for (int j = 1; j < g.size(); j++)
        if (fabs(g[j] - g[j - 1]) < (1e-12))
          now++;
        else {
          ans += now * (now - 1) / 2;
          now = 1;
        }
      ans += now * (now - 1) / 2;
    }
  ans /= 3;
  if (zero == 2) ans += n - 2;
  printf("%I64d\n", ans);
  return 0;
}
