#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
int n, a[2001], b[2001], c[2001];
map<pair<long long, long long>, int> cnt;
pair<pair<long long, long long>, pair<long long, long long> > p[2001];
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void calc(int i, int a1, int b1, int c1) {
  pair<long long, long long> x, y;
  x = make_pair(a1 * c1, (a1 * a1) + (b1 * b1));
  y = make_pair(c1 * b1, (a1 * a1) + (b1 * b1));
  p[i] = make_pair(x, y);
}
long long calc2(long long i) { return (i * (i - 1)) / 2; }
int main() {
  cin >> n;
  long long ans = 0, zero = 0;
  int t = gcd(0, 0);
  int tt = gcd(0, 1);
  int ttt = gcd(1, 0);
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
  for (int i = 0; i < n; i++) {
    calc(i, a[i], b[i], c[i]);
    if (c[i] == 0) zero++;
  }
  if (zero == 2) ans += n - 2;
  for (int i = 0; i < n; i++)
    if (c[i]) {
      cnt.clear();
      for (int j = i + 1; j < n; j++)
        if (c[j]) {
          long long sx = (p[i].first.first * p[j].first.second) -
                         (p[j].first.first * p[i].first.second);
          long long mx = p[i].first.second * p[j].first.second;
          long long sy = (p[i].second.first * p[j].second.second) -
                         (p[j].second.first * p[i].second.second);
          long long my = p[i].second.second * p[j].second.second;
          long long s = sy * mx;
          long long m = sx * my;
          long long g = gcd(abs(s), abs(m));
          s /= g;
          m /= g;
          if (m == 0)
            s = 1;
          else if (s == 0)
            m = 1;
          if (m < 0) s *= -1, m *= -1;
          cnt[make_pair(s, m)]++;
        }
      for (auto i : cnt) {
        ans += calc2(i.second);
      }
    }
  cout << ans << endl;
  return 0;
}
