#include <bits/stdc++.h>
using namespace std;
long long n, a[2001], b[2001], c[2001], res, zero;
vector<pair<long long, long long> > v;
long long _abs(long long x) { return x > 0 ? x : -x; }
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
pair<long long, long long> reduce(long long x, long long y) {
  long long g = gcd(_abs(x), _abs(y));
  x /= g;
  y /= g;
  if (x < 0 || (x == 0 && y < 0)) {
    x = -x, y = -y;
  }
  return make_pair(x, y);
}
int main() {
  res = 0;
  zero = 0;
  scanf("%d", &n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    if (c[i] == 0) zero++;
  }
  if (zero == 2) res += n - 2;
  for (long long i = 0; i < n; i++) {
    v.clear();
    if (zero == 2 && c[i] == 0) continue;
    for (long long j = i + 1; j < n; j++) {
      if (zero == 2 && c[j] == 0) continue;
      long long _u = (a[j] * a[j] + b[j] * b[j]) * b[i] * c[i] -
                     (a[i] * a[i] + b[i] * b[i]) * b[j] * c[j];
      long long _v = (a[j] * a[j] + b[j] * b[j]) * a[i] * c[i] -
                     (a[i] * a[i] + b[i] * b[i]) * a[j] * c[j];
      v.push_back(reduce(_u, _v));
    }
    sort(v.begin(), v.end());
    long long _i = 0;
    while (_i < v.size()) {
      long long _j = _i + 1;
      while (_j < v.size()) {
        if (v[_i] != v[_j]) break;
        _j++;
      }
      long long x = _j - _i;
      res += x * (x - 1) / 2;
      _i = _j;
    }
  }
  cout << res << endl;
}
