#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) { return x ? gcd(y % x, x) : y; }
int N;
int a[2010], b[2010], c[2010];
vector<pair<long long, long long> > v;
long long func(void) {
  int i, j;
  int ans = 0;
  i = 0;
  while (i < v.size()) {
    for (j = i; j < v.size(); j++)
      if (v[j] != v[i]) break;
    int d = j - i;
    ans += d * (d - 1) / 2;
    i = j;
  }
  return ans;
}
int main(void) {
  int i, j;
  cin >> N;
  for ((i) = 0; (i) < (int)(N); (i)++) scanf("%d%d%d", &a[i], &b[i], &c[i]);
  long long ans = 0;
  int zero = 0;
  for ((i) = 0; (i) < (int)(N); (i)++)
    if (c[i] == 0) zero++;
  if (zero == 2) ans += N - 2;
  for ((i) = 0; (i) < (int)(N); (i)++)
    if (c[i] != 0) {
      v.clear();
      long long px = a[i] * a[i] + b[i] * b[i];
      long long qx = a[i] * c[i];
      long long py = a[i] * a[i] + b[i] * b[i];
      long long qy = b[i] * c[i];
      for ((j) = 0; (j) < (int)(i); (j)++)
        if (c[j] != 0) {
          long long px2 = a[j] * a[j] + b[j] * b[j];
          long long qx2 = a[j] * c[j];
          long long py2 = a[j] * a[j] + b[j] * b[j];
          long long qy2 = b[j] * c[j];
          long long rx = px * px2;
          long long sx = qx * px2 - px * qx2;
          long long ry = py * py2;
          long long sy = qy * py2 - py * qy2;
          long long g =
              gcd(((sx) > 0 ? (sx) : -(sx)), ((sy) > 0 ? (sy) : -(sy)));
          sx /= g;
          sy /= g;
          if (sx < 0 || (sx == 0 && sy < 0)) {
            sx = -sx;
            sy = -sy;
          }
          v.push_back(make_pair(sx, sy));
        }
      sort(v.begin(), v.end());
      long long tmp = func();
      ans += tmp;
    }
  cout << ans << endl;
  return 0;
}
