#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
long long a[2000 + 10];
long long b[2000 + 10];
long long r[2000 + 10];
long long gcd(long long X, long long Y) {
  if (X < Y) swap(X, Y);
  long long tmp;
  while (X != 0) {
    tmp = X;
    X = Y % X;
    Y = tmp;
  }
  return Y;
}
void krajsaj(pair<long long, long long>& p) {
  long long g = gcd(p.first, p.second);
  if (g != 0) p.first /= g, p.second /= g;
  if (p.second < 0) {
    p.first *= -1;
    p.second *= -1;
  }
  if (p.first < 0 && p.second == 0) {
    p.first *= -1;
    p.second *= -1;
  }
}
int main() {
  long long n;
  scanf("%lld", &n);
  for (int i = 0, _n = n; i < _n; i++) {
    long long x, y, z;
    scanf("%lld%lld%lld", &x, &y, &z);
    a[i] = x * z;
    b[i] = y * z;
    r[i] = x * x + y * y;
  }
  long long rez = 0;
  for (int i = 0, _n = n; i < _n; i++) {
    map<pair<long long, long long>, long long> k;
    long long same = 0;
    long long num = 0;
    for (int j = i + 1, _n = n; j < _n; j++) {
      if (a[i] * r[j] == a[j] * r[i] && b[i] * r[j] == b[j] * r[i]) {
        rez += num++;
        same++;
        continue;
      }
      pair<long long, long long> tr =
          make_pair(b[j] * r[i] - b[i] * r[j], a[j] * r[i] - a[i] * r[j]);
      krajsaj(tr);
      rez += k[tr] + same;
      k[tr]++;
      num++;
    }
  }
  printf("%d\n", rez);
  return 0;
}
