#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
const int Q = 1e9 + 7;
int n;
pair<long double, long double> P[N];
const long double eps = 1e-12;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int A, B, C;
    scanf("%d%d%d", &A, &B, &C);
    int D = A * A + B * B;
    P[i].first = (long double)A * C / D;
    P[i].second = (long double)B * C / D;
  }
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    vector<long double> V;
    int flag = 0;
    for (int j = i + 1; j < n; ++j) {
      pair<long double, long double> v(P[j].first - P[i].first,
                                       P[j].second - P[i].second);
      if (fabs(v.first) < eps && fabs(v.second) < eps) {
        flag = 1;
      } else if (fabs(v.first) < eps) {
        V.push_back(1e100);
      } else {
        V.push_back(v.second / v.first);
      }
    }
    if (flag) res += V.size();
    sort(V.begin(), V.end());
    for (int j = 0; j < V.size(); ++j) {
      int k = j;
      while (k < V.size() && fabs(V[k] - V[j]) < eps) ++k;
      res += (k - j) * (k - j - 1) / 2;
      j = k - 1;
    }
  }
  cout << res << endl;
  return 0;
}
