#include <bits/stdc++.h>
using namespace std;
int n, aa[2005], bb[2005], cc[2005], cnt;
long long ans;
long double PI = 3.14159265358979323846264338327950288419716939937510, ta, tb,
            tc, td, te, tf, tg, th, eps = 1e-10;
map<long double, int> y;
int main() {
  scanf("%d", &n);
  for (int a = 0; a < n; a++) scanf("%d%d%d", &aa[a], &bb[a], &cc[a]);
  for (int a = 0; a < n; a++) {
    if (cc[a] == 0) {
      cnt++;
      continue;
    }
    ta = atan2((long double)-aa[a], (long double)bb[a]);
    y.clear();
    for (int b = 0; b < n; b++)
      if (a != b && cc[b] != 0) {
        tb = aa[a] * bb[b] - bb[a] * aa[b];
        tc = (cc[a] * bb[b] - bb[a] * cc[b]);
        td = (aa[a] * cc[b] - cc[a] * aa[b]);
        te = atan2(td, tc);
        while (te < 0) te += PI;
        while (te >= PI) te -= PI;
        tf = atan2((long double)-aa[b], (long double)bb[b]);
        while (tf < 0) tf += PI;
        while (tf >= PI) tf -= PI;
        if (abs(te - PI) < eps) te = 0;
        if (abs(tf - PI) < eps) tf = 0;
        th = (te - tf) * 2;
        while (th < 0) th += PI * 2;
        while (th >= PI * 2) th -= PI * 2;
        if (abs(th - PI * 2) < eps) th = 0;
        th = round(th / eps);
        ans += y[th];
        y[th]++;
      }
  }
  ans /= 3;
  if (cnt == 2) ans += n - 2;
  printf("%I64d\n", ans);
  return 0;
}
