#include <bits/stdc++.h>
using namespace std;
const int MAX = 10000 + 10;
const int NUM = 1002 * 1002;
const int Mod = 1e9 + 7;
const long double EPS = 1e-9;
struct Point {
  long double first, second;
  void change() {
    long double d = 1.0 / (first * first + second * second);
    first *= d;
    second *= d;
  }
} d[MAX];
int same(long double a, long double b) { return abs(a - b) < EPS; }
int operator<(const Point& a, const Point& b) {
  if (same(a.first, b.first))
    return a.second < b.second;
  else
    return a.first < b.first;
}
int operator==(const Point& a, const Point& b) {
  return same(a.first, b.first) && same(a.second, b.second);
}
int n;
int tot;
Point line[NUM];
int a[NUM], b[NUM];
int num[NUM];
int cmp(int a, int b) { return line[a] < line[b]; }
int main() {
  int i, j;
  scanf("%d", &n);
  for ((i) = (1); (i) <= (n); ++(i)) {
    int a, b, c, e;
    cin >> a >> b >> c >> e;
    d[i].first = (long double)a * b * e * e / (a * a * e * e + b * b * c * c);
    d[i].second = (long double)b * b * c * e / (a * a * e * e + b * b * c * c);
  }
  int tot = 0;
  for ((i) = (1); (i) <= (n); ++(i))
    for ((j) = (i + 1); (j) <= (n); ++(j)) {
      ++tot;
      a[tot] = i;
      b[tot] = j;
      line[tot].first = d[j].first + d[i].first;
      line[tot].second = d[j].second + d[i].second;
      num[tot] = tot;
    }
  sort(num + 1, num + tot + 1, cmp);
  long long answer = 0;
  for (i = 1; i <= tot;) {
    Point e = line[num[i]];
    vector<long double> v;
    for (; i <= tot && line[num[i]] == e; ++i) {
      int first = a[num[i]];
      int second = b[num[i]];
      if (d[first] < d[second]) swap(first, second);
      v.push_back(atan2(d[second].second - d[first].second,
                        d[second].first - d[first].first));
    }
    if (v.size() < 2) continue;
    long long ans = 1;
    sort(v.begin(), v.end());
    for (j = 0; j < (int)v.size();) {
      int num = 1;
      long double first = v[j];
      for (; j < (int)v.size() && same(v[j], first); ++j) ++num;
      ans = ans * num % Mod;
    }
    answer += ans - v.size() - 1;
    if (answer < 0) answer += Mod;
    if (answer >= Mod) answer -= Mod;
  }
  cout << answer << endl;
  return 0;
}
