#include <bits/stdc++.h>
using namespace std;
long long a[2010], b[2010], c[2010];
long long ac[2010], bc[2010], a2b2[2010];
int n;
int same;
struct point {
  long long x, y;
  friend bool operator<(point a, point b) {
    if (a.x != b.x)
      return a.x < b.x;
    else
      return a.y < b.y;
  }
  friend bool operator==(point a, point b) {
    return (a.x == b.x) && (a.y == b.y);
  }
  friend bool operator!=(point a, point b) {
    return (a.x != b.x) || (a.y != b.y);
  }
};
point grad[2010];
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
void simple(long long &a, long long &b) {
  if (a == 0) {
    if (b == 0)
      return;
    else {
      b = 1;
      return;
    }
  }
  if (b == 0) {
    a = 1;
    return;
  }
  if (a < 0) {
    a = -a;
    b = -b;
  }
  if (b != 0 && a != 0) {
    long long ggcd = gcd(a, abs(b));
    a = a / ggcd;
    b = b / ggcd;
  }
}
int main() {
  while (scanf("%d", &n) == 1) {
    int cou0 = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%I64d%I64d%I64d", &a[i], &b[i], &c[i]);
      ac[i] = a[i] * c[i];
      bc[i] = b[i] * c[i];
      a2b2[i] = a[i] * a[i] + b[i] * b[i];
      if (c[i] == 0) cou0++;
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      int top = -1;
      for (int j = i + 1; j <= n; j++) {
        grad[++top].x = a2b2[j] * ac[i] - a2b2[i] * ac[j];
        grad[top].y = a2b2[j] * bc[i] - a2b2[i] * bc[j];
        simple(grad[top].x, grad[top].y);
      }
      sort(grad, grad + top + 1);
      int p = 0;
      int same0 = 0;
      while (p <= top && grad[p].x == 0 && grad[p].y == 0) {
        same0++;
        p++;
      }
      point tmp = grad[p];
      p++;
      int same = 1;
      while (p <= top) {
        if (grad[p] != tmp) {
          ans += (same) * (same - 1) / 2;
          same = 1;
          tmp = grad[p];
        } else
          same++;
        p++;
      }
      ans += (same) * (same - 1) / 2;
      ans += same0 * (top + 1 - same0) + same0 * (same0 - 1) / 2;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
