#include <bits/stdc++.h>
using namespace std;
int n;
double x[2005], y[2005], k[2005];
const double eps = 1e-12;
long long ans;
inline int read() {
  int w = 0, f = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    w = (w << 1) + (w << 3) + ch - '0', ch = getchar();
  return w * f;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    double a = read(), b = read(), c = read();
    x[i] = a * c / (a * a + b * b), y[i] = b * c / (a * a + b * b);
  }
  for (int i = 1; i <= n - 2; i++) {
    int tot = 0, sum = 0, pos = 1;
    for (int j = i + 1; j <= n; j++)
      if (x[i] == x[j] && y[i] == y[j])
        ++sum;
      else if (x[i] != x[j])
        k[++tot] = (y[j] - y[i]) / (x[j] - x[i]);
      else
        k[++tot] = 1e9;
    sort(k + 1, k + tot + 1);
    for (int j = 1; j <= sum; j++) ans += n - i - j;
    for (int j = 1; j <= tot; j++) {
      while (abs(k[pos] - k[j]) > eps) ++pos;
      ans += j - pos;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
