#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  for (; b > 0; swap(a, b)) a %= b;
  return a;
}
pair<long long, long long> reduce(long long x, long long y) {
  long long g = gcd(abs(x), abs(y));
  if (g != 0) x /= g, y /= g;
  if (y < 0 || (y == 0 && x < 0)) x = -x, y = -y;
  return make_pair(x, y);
}
int main() {
  int sol = 0;
  int n;
  cin >> n;
  long long a, b, c;
  vector<long long> X;
  vector<long long> Z;
  vector<long long> Y;
  int g2 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    if (c == 0) {
      g2++;
      continue;
    }
    X.push_back(a * c);
    Y.push_back(b * c);
    Z.push_back(a * a + b * b);
  }
  if (g2 == 2) sol += n - 2;
  n = X.size();
  for (int i = 0; i < n; i++) {
    map<pair<long long, long long>, int> v2c;
    for (int j = i + 1; j < n; j++) {
      long long dx = X[i] * Z[j] - X[j] * Z[i];
      long long dy = Y[i] * Z[j] - Y[j] * Z[i];
      pair<long long, long long> v = reduce(dx, dy);
      sol += v2c[v]++;
    }
  }
  cout << sol << endl;
  return 0;
}
