#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> pll;
long long gcd(long long x, long long y) {
  for (; y > 0; swap(x, y)) x %= y;
  return x;
}
pll align(long long x, long long y) {
  long long g = gcd(abs(x), abs(y));
  if (g) {
    x /= g;
    y /= g;
  }
  if (x > 0 || (x == 0 && y >= 0))
    return pll(x, y);
  else
    return pll(-x, -y);
}
long long X[2002], Y[2002], C[2002];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    X[i] = a * c;
    Y[i] = b * c;
    C[i] = a * a + b * b;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    map<pll, int> m;
    long long tot = 0, z = 0;
    for (int j = i + 1; j < n; j++) {
      long long x = X[i] * C[j] - X[j] * C[i];
      long long y = Y[i] * C[j] - Y[j] * C[i];
      auto v = align(x, y);
      if (v.first || v.second) {
        ans += m[v] + z;
        m[v]++;
      } else {
        ans += tot;
        z++;
      }
      tot++;
    }
  }
  cout << ans;
}
