#include <bits/stdc++.h>
using namespace std;
int n, a[100010], b[100010], c[100010];
long long x[100010], y[100010], k[100010], cnt, ans;
map<pair<long long, long long>, int> mp;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    k[i] = a[i] * a[i] + b[i] * b[i];
    x[i] = -(a[i] * c[i]);
    y[i] = -(b[i] * c[i]);
    if (c[i] == 0) cnt++;
  }
  if (cnt >= 2) ans += (n - 2);
  for (int i = 1; i <= n; i++) {
    if (c[i] == 0) continue;
    mp.clear();
    for (int j = i + 1; j <= n; j++) {
      if (!c[j]) continue;
      long long s = x[i] * k[j] - x[j] * k[i];
      long long t = y[i] * k[j] - y[j] * k[i];
      long long mem = gcd(fabs(s), fabs(t));
      s /= mem, t /= mem;
      if (s < 0 || (s == 0 && t < 0)) {
        s = -s;
        t = -t;
      }
      mp[make_pair(s, t)]++;
    }
    for (map<pair<long long, long long>, int>::iterator it = mp.begin();
         it != mp.end(); it++) {
      long long tp = (*it).second;
      ans = ans + (tp - 1) * tp / 2;
    }
  }
  printf("%lld", ans);
  return 0;
}
