#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<long double, long double> > v(n);
  int k = 0;
  for (int i = 0; i < n; ++i) {
    long double a, b, c;
    cin >> a >> b >> c;
    if (c == 0) ++k;
    long double m = a * a + b * b;
    v[i].first = -a * c / m;
    v[i].second = -b * c / m;
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (v[i].first != 0 || v[i].second != 0 || k < 2) {
      map<double, int> m;
      int inf = 0;
      for (int j = i + 1; j < n; ++j) {
        long double dy = v[i].second - v[j].second,
                    dx = v[i].first - v[j].first;
        if (dx == 0)
          ++inf;
        else
          ++m[double(dy / dx)];
      }
      ans += (inf * (inf - 1)) / 2;
      for (auto it = m.begin(); it != m.end(); ++it) {
        ans += ((it->second) * (it->second - 1)) / 2;
      }
    } else {
      --k;
      map<double, int> m;
      int inf = 0;
      for (int j = i + 1; j < n; ++j) {
        long double dy = v[i].second - v[j].second,
                    dx = v[i].first - v[j].first;
        if (dx == 0)
          ++inf;
        else
          ++m[double(dy / dx)];
      }
      ans += ((inf - 1) * (inf - 2)) / 2;
      for (auto it = m.begin(); it != m.end(); ++it) {
        ans += ((it->second) * (it->second - 1)) / 2;
      }
      ans += n - i - 2;
    }
  }
  cout << ans << endl;
}
