#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
const double eps = 1e-12;
int n;
double x[N], y[N];
long long ans;
inline int C2(int x) { return x * (x - 1) / 2; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    double a, b, c;
    scanf("%lf%lf%lf", &a, &b, &c);
    x[i] = a * c / (a * a + b * b), y[i] = b * c / (a * a + b * b);
  }
  for (int i = 1; i <= n; i++) {
    vector<double> slope;
    int cnt = 0;
    for (int j = i + 1; j <= n; j++) {
      if (abs(x[i] - x[j]) < eps && abs(y[i] - y[j]) < eps)
        cnt++;
      else if (abs(x[i] - x[j]) > eps)
        slope.push_back((y[i] - y[j]) / (x[i] - x[j]));
      else
        slope.push_back(1e18);
    }
    ans += (n - i) * cnt - C2(cnt + 1);
    sort(slope.begin(), slope.end());
    for (int i = 0, j = 0; i < slope.size(); i = j + 1) {
      while (j + 1 < slope.size() && abs(slope[j + 1] - slope[i]) < eps) j++;
      ans += C2(j - i + 1);
    }
  }
  printf("%lld", ans);
  return 0;
}
