#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
int n, a[2015], b[2015], c[2015];
long long px[2015], qx[2015], py[2015], qy[2015], rx, ry;
long long gcd(long long x, long long y) {
  while (y) y ^= x ^= y ^= x %= y;
  return x;
}
int flag;
map<pair<long long, long long>, int> mmp;
long long ans = 0;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    if (!c[i]) ++flag;
    px[i] = (long long)a[i] * c[i], py[i] = (long long)b[i] * c[i];
    qx[i] = qy[i] = (long long)a[i] * a[i] + (long long)b[i] * b[i];
  }
  for (int i = 1; i <= n; ++i) {
    if (!c[i]) continue;
    mmp.clear();
    for (int j = 1; j < i; ++j) {
      if (!c[j]) continue;
      rx = px[i] * qx[j] - px[j] * qx[i];
      ry = py[i] * qy[j] - py[j] * qy[i];
      long long g = gcd(rx, ry);
      rx /= g, ry /= g;
      if (rx < 0 || !rx && ry < 0) {
        rx = -rx;
        ry = -ry;
      }
      ++mmp[pair<long long, long long>(rx, ry)];
    }
    for (map<pair<long long, long long>, int>::iterator it = mmp.begin();
         it != mmp.end(); ++it) {
      long long x = (*it).second;
      ans += x * (x - 1) >> 1;
    }
  }
  if (2 == flag) ans += n - 2;
  printf("%I64d\n", ans);
  return 0;
}
