#include <bits/stdc++.h>
using namespace std;
int N, a, b, c, rez;
vector<pair<long double, long double> > v;
vector<long double> s;
long double inf = 1000000000;
bool eq(long double a, long double b) {
  long double eps = 0.00000000001;
  return (a - b > -eps && a - b < eps);
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a >> b >> c;
    if (a == 0) {
      v.push_back(make_pair(0, -c * 1.0 / b));
    } else if (b == 0) {
      v.push_back(make_pair(-c * 1.0 / a, 0));
    } else {
      long double x = -1.0 * c / b / (1.0 * a / b + 1.0 * b / a);
      v.push_back(make_pair(x, x * b / a));
    }
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < N; ++i) {
    s.clear();
    for (int j = i + 1; j < N; ++j) {
      if (eq(v[i].first, v[j].first) && eq(v[i].second, v[j].second)) {
        rez += N - i - 2;
      } else {
        if (eq(v[j].first, v[i].first)) {
          s.push_back(inf);
        } else {
          s.push_back(1.0 * (v[j].second - v[i].second) /
                      (v[j].first - v[i].first));
        }
      }
    }
    sort(s.begin(), s.end());
    long double curr = s[0];
    int cnt = 1;
    for (int j = 1; j < s.size(); ++j) {
      if (eq(s[j], s[j - 1])) {
        ++cnt;
      } else {
        rez += cnt * (cnt - 1) / 2;
        curr = s[j];
        cnt = 1;
      }
    }
    rez += cnt * (cnt - 1) / 2;
  }
  cout << rez;
  return 0;
}
