#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-12;
const int maxn = 3005;
const long double inf = 1e108;
inline bool deng(long double a, long double b) { return fabs(a - b) <= eps; }
struct Point {
  long double x, y;
  int id;
  friend bool operator==(Point a, Point b) {
    return deng(a.x, b.x) && deng(a.y, b.y);
  }
} p[maxn];
map<long double, int> mp;
inline long double getK(Point a, Point b) {
  if (deng(a.y, b.y)) return inf;
  return (a.x - b.x) / (a.y - b.y);
}
vector<long double> ve;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    long double a, b, c;
    cin >> a >> b >> c;
    p[i].x = a * c / (a * a + b * b);
    p[i].y = b * c / (a * a + b * b);
    p[i].id = i;
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    ve.clear();
    int sum = 0;
    for (int j = i + 1; j <= n; ++j) {
      if (p[i] == p[j])
        sum++;
      else
        ve.push_back(getK(p[j], p[i]));
    }
    ans += sum * (int)ve.size() + (sum * (sum - 1) >> 1);
    sort(ve.begin(), ve.end());
    sum = 1;
    for (unsigned i = 1; i < ve.size(); ++i) {
      if (deng(ve[i], ve[i - 1])) {
        ans += sum;
        sum++;
      } else
        sum = 1;
    }
  }
  cout << ans;
  return 0;
}
