#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
T sqr(const T &x) {
  return x * x;
}
template <class T>
T lowbit(const T &x) {
  return (x ^ (x - 1)) & x;
}
template <class T>
int countbit(const T &n) {
  return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
template <class T>
void ckmin(T &a, const T &b) {
  if (b < a) a = b;
}
template <class T>
void ckmax(T &a, const T &b) {
  if (b > a) a = b;
}
const int maxn = 2048;
int n;
double x[maxn], y[maxn];
double p[maxn];
int main() {
  std::ios_base::sync_with_stdio(false);
  while (cin >> n) {
    int m = 0, w = 0;
    for (int i = 0; i < (n); ++i) {
      int a, b, c;
      cin >> a >> b >> c;
      if (c == 0) {
        w++;
        continue;
      }
      int d = a * a + b * b;
      x[m] = (double)(a * c) / d;
      y[m++] = (double)(b * c) / d;
    }
    n = m;
    int ret = (w * (w - 1) / 2) * n;
    for (int k = 0; k < (n); ++k) {
      for (int i = 0; i < (k); ++i) {
        double d = atan2(y[i] - y[k], x[i] - x[k]);
        for (; d < -eps; d += pi)
          ;
        for (; d >= pi - eps; d -= pi)
          ;
        p[i] = d;
      }
      sort(p, p + k);
      for (int i = 0; i < (k); ++i) {
        int c = 1;
        for (int j = (i + 1); j < (k); ++j)
          if (p[j] - p[i] <= eps)
            c++;
          else
            break;
        ret += c * (c - 1) / 2;
        i += (c - 1);
      }
    }
    printf("%d\n", ret);
  }
  return 0;
}
