#include <bits/stdc++.h>
using namespace std;
struct line_item {
  long double a, b, c;
  long double mx, my, d;
};
inline bool equal(long double x, long double y) { return (abs(x - y) < 1e-14); }
inline int sign(long double x) {
  if (abs(x) < 1e-14)
    return 0;
  else if (x < 0)
    return -1;
  else
    return 1;
}
inline long double angle_ray(line_item *lines, int i, long double x,
                             long double y) {
  int dir;
  if (equal(lines[i].my, 0))
    dir = -sign(lines[i].mx * y);
  else if (lines[i].my < 0)
    dir = sign(lines[i].mx - x);
  else
    dir = sign(x - lines[i].mx);
  return dir * lines[i].d / (x * x + y * y);
}
inline long double det2(long double a1, long double a2, long double b1,
                        long double b2) {
  return (a1 * b2 - a2 * b1);
}
long double intersect(long double a1, long double a2, long double b1,
                      long double b2, long double c1, long double c2) {
  long double tmp;
  tmp = det2(a1, a2, c1, c2);
  if (tmp == 0)
    return 0;
  else
    return tmp / det2(a1, a2, b1, b2);
}
int main() {
  int i, j, k;
  int circles = 0;
  int cross_num = 0;
  bool orgone = false;
  long double x, y;
  int n;
  cin >> n;
  line_item lines[n];
  double crossings[n];
  for (i = 0; i < n; i++) {
    cin >> lines[i].a >> lines[i].b >> lines[i].c;
    if (lines[i].c == 0) {
      i--;
      n--;
      if (orgone)
        circles = n;
      else
        orgone = true;
    } else {
      lines[i].d =
          lines[i].c / (lines[i].a * lines[i].a + lines[i].b * lines[i].b);
      lines[i].mx = lines[i].a * lines[i].d;
      lines[i].my = lines[i].b * lines[i].d;
      lines[i].d *= lines[i].c;
    }
  }
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      x = intersect(lines[i].b, lines[j].b, lines[i].a, lines[j].a, lines[i].c,
                    lines[j].c);
      y = intersect(lines[i].a, lines[j].a, lines[i].b, lines[j].b, lines[i].c,
                    lines[j].c);
      crossings[j] = angle_ray(lines, j, x, y);
    }
    sort(crossings + i + 1, crossings + n);
    k = i + 1;
    while (k < n - 1) {
      j = k + 1;
      while ((j < n) && equal(crossings[k], crossings[j])) j++;
      circles += (j - k) * (j - k - 1) / 2;
      k = j;
    }
  }
  cout << circles << endl;
}
