#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  long long r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = 2 * acos((long double)0);
const int maxn = 2010;
int n;
long long a[maxn];
long long b[maxn];
long long c[maxn];
void solve() {
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) scanf("%I64d%I64d%I64d", a + i, b + i, c + i);
  long long ans = 0;
  for (int i = (0); i < (n); i++) {
    map<pair<long long, long long>, int> cnt;
    int s = 0, t = 0;
    for (int j = (i + 1); j < (n); j++) {
      long long x = a[i] * a[i] + b[i] * b[i];
      long long y = a[j] * a[j] + b[j] * b[j];
      long long u = c[j] * a[j] * x - c[i] * a[i] * y;
      long long v = c[j] * b[j] * x - c[i] * b[i] * y;
      if (!u && !v)
        s++;
      else {
        long long g = gcd(abs(u), abs(v));
        u /= g;
        v /= g;
        if (!u) {
          if (v < 0) {
            u *= -1;
            v *= -1;
          }
        } else if (u < 0) {
          u *= -1;
          v *= -1;
        }
        ans += cnt[make_pair(u, v)]++;
        t++;
      }
    }
    ans += 1LL * s * (s - 1) / 2;
    ans += 1LL * s * t;
  }
  printf("%I64d", ans);
}
int main() {
  solve();
  return 0;
}
