#include <bits/stdc++.h>
using namespace std;
int quad(complex<long long int> v) {
  if (v.real() >= 0) {
    if (v.imag() >= 0) {
      return 0;
    } else {
      return 3;
    }
  } else {
    if (v.imag() >= 0) {
      return 1;
    } else {
      return 2;
    }
  }
}
namespace std {
bool operator<(complex<long long int> a, complex<long long int> b) {
  int qa = quad(a);
  int qb = quad(b);
  if (qa != qb) return qa < qb;
  double fval =
      (double)b.imag() * (double)a.real() - (double)b.real() * (double)a.imag();
  if (std::abs(fval) < 1e12) {
    long long int val = b.imag() * a.real() - b.real() * a.imag();
    return val > 0;
  } else {
    return fval > 0.0;
  }
}
}  // namespace std
bool samedir(complex<long long int> a, complex<long long int> b) {
  double fval =
      (double)b.imag() * (double)a.real() - (double)b.real() * (double)a.imag();
  if (std::abs(fval) < 1e12) {
    long long int val = b.imag() * a.real() - b.real() * a.imag();
    return val == 0;
  } else {
    return false;
  }
}
int n;
long long int a[2048];
long long int b[2048];
long long int c[2048];
int main() {
  cin.sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  long long int ret = 0;
  vector<complex<long long int> > T;
  for (int i = 0; i < n; ++i) {
    T.clear();
    for (int j = 0; j < n; ++j) {
      if (j == i) continue;
      complex<long long int> p(b[j] * c[i] - b[i] * c[j],
                               -a[j] * c[i] + a[i] * c[j]);
      p *= conj(complex<long long int>(b[j], -a[j]));
      if (p.imag() < 0) p = -p;
      if (p == (complex<long long int>)0) {
        ret += 2 * n - 4;
      } else {
        T.push_back(p);
      }
    }
    sort(T.begin(), T.end());
    int j = 0;
    while (j < (int)T.size()) {
      int s = j;
      ++j;
      while (j < (int)T.size() && samedir(T[j], T[s])) ++j;
      long long int sz = j - s;
      ret += sz * (sz - 1);
    }
  }
  cout << ret / 6 << "\n";
  return 0;
}
