#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
int n, k;
struct line {
  int a, b, c;
};
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
struct fraq {
  long long a, b;
  bool operator<(const fraq oth) const {
    if (a * oth.b < b * oth.a) return true;
    return false;
  }
  bool operator==(const fraq oth) const {
    if (a * oth.b == oth.a * b) return true;
    return false;
  }
  void norm() {
    long long g = gcd(a, b);
    a /= g;
    b /= g;
    if (b < 0) b = -b, a = -a;
  }
};
line mas[MAXN];
pair<fraq, fraq> point[MAXN];
map<fraq, int> cnt;
int was[MAXN];
void solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> mas[i].a >> mas[i].b >> mas[i].c;
  }
  for (int i = 0; i < n; ++i) {
    int a = mas[i].a, b = mas[i].b, c = mas[i].c;
    int dec = b * b + a * a;
    point[i].second.a = b * c;
    point[i].second.b = dec;
    point[i].second.norm();
    point[i].first.a = a * c;
    point[i].first.b = dec;
    point[i].first.norm();
  }
  long long ans = 0;
  int k = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (point[i] == point[j]) {
        was[j] = 1;
        k++;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (was[i]) continue;
    cnt.clear();
    long long a1 = point[i].first.a;
    long long b1 = point[i].first.b;
    long long c1 = point[i].second.a;
    long long d1 = point[i].second.b;
    for (int j = i + 1; j < n; ++j) {
      if (was[j]) continue;
      long long a2 = point[j].first.a;
      long long b2 = point[j].first.b;
      long long c2 = point[j].second.a;
      long long d2 = point[j].second.b;
      fraq t;
      t.a = (a1 * b2 - b1 * a2) * d1 * d2;
      t.b = (c1 * d2 - d1 * c2) * b1 * b2;
      t.norm();
      cnt[t]++;
    }
    for (auto it = cnt.begin(); it != cnt.end(); ++it) {
      int k = (*it).second;
      ans += k * (k - 1) / 2;
    }
  }
  ans += k * (n - 2);
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  solve();
  return 0;
}
