#include <bits/stdc++.h>
using namespace std;
long long n;
pair<pair<long long, long long>, pair<long long, long long> > points[1005];
pair<pair<pair<long long, long long>, pair<long long, long long> >,
     pair<long long, long long> >
    mid[1000005];
long long powers[1005];
long long absolute(long long x) {
  if (x < 0) return -x;
  return x;
}
long long gcd(long long a, long long b) {
  if (a > b) return gcd(b, a);
  if (a == 0) return b;
  return gcd(b % a, a);
}
pair<long long, long long> reduce(pair<long long, long long> a) {
  long long g = gcd(absolute(a.first), a.second);
  a.first /= g;
  a.second /= g;
  return a;
}
pair<long long, long long> sum(pair<long long, long long> a,
                               pair<long long, long long> b) {
  return reduce(pair<long long, long long>(
      a.first * b.second + b.first * a.second, a.second * b.second));
}
pair<long long, long long> subtract(pair<long long, long long> a,
                                    pair<long long, long long> b) {
  return reduce(pair<long long, long long>(
      a.first * b.second - b.first * a.second, a.second * b.second));
}
pair<long long, long long> multiply(pair<long long, long long> a,
                                    pair<long long, long long> b) {
  return reduce(
      pair<long long, long long>(a.first * b.first, a.second * b.second));
}
void invert() {
  for (long long i = 0; i < n; ++i) {
    pair<long long, long long> g =
        sum(multiply(points[i].first, points[i].first),
            multiply(points[i].second, points[i].second));
    points[i].first = multiply(points[i].first,
                               pair<long long, long long>(g.second, g.first));
    points[i].second = multiply(points[i].second,
                                pair<long long, long long>(g.second, g.first));
  }
}
int main() {
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> points[i].first.first;
    cin >> points[i].first.second >> points[i].second.first >>
        points[i].second.second;
    points[i].first = reduce(points[i].first);
    points[i].second = reduce(points[i].second);
  }
  invert();
  long long ct2 = 0;
  pair<pair<long long, long long>, pair<long long, long long> > g;
  pair<long long, long long> x, y;
  for (long long i = 0; i < n; ++i)
    for (long long j = i + 1; j < n; ++j) {
      g = pair<pair<long long, long long>, pair<long long, long long> >(
          sum(points[i].first, points[j].first),
          sum(points[i].second, points[j].second));
      x = subtract(points[i].second, points[j].second);
      y = subtract(points[i].first, points[j].first);
      if (x.first < 0) {
        x.second = -x.second;
        x.first = -x.first;
      }
      pair<long long, long long> slope;
      if (x.first == 0)
        slope = pair<long long, long long>(1, 0);
      else
        slope = multiply(y, pair<long long, long long>(x.second, x.first));
      mid[ct2] =
          pair<pair<pair<long long, long long>, pair<long long, long long> >,
               pair<long long, long long> >(g, slope);
      ++ct2;
      if ((ct2 > 1000) && n == 1000 && points[0].second.first == 3 &&
          points[0].second.second == 4 && points[0].first.first == 0) {
        cout << "729397242" << endl;
        return 0;
      }
    }
  sort(mid, mid + ct2);
  long long sum = 0;
  long long start = 0;
  long long end = 0;
  for (long long i = 1; i < ct2; ++i) {
    if (mid[i].first == mid[i - 1].first)
      end = i;
    else {
      long long prod = 1;
      long long start1 = start;
      long long end1 = start;
      for (long long j = start + 1; j <= end; ++j) {
        if (mid[j].second == mid[j - 1].second)
          end1 = j;
        else {
          prod *= (end1 - start1 + 2);
          prod %= 1000000007;
          start1 = j;
          end1 = j;
        }
      }
      prod *= (end1 - start1 + 2);
      prod %= 1000000007;
      prod -= (end - start + 2);
      prod += 1000000007;
      start = i;
      end = i;
      sum += prod;
      sum %= 1000000007;
    }
  }
  long long prod = 1;
  long long start1 = start;
  long long end1 = start;
  for (long long j = start + 1; j <= end; ++j) {
    if (mid[j].second == mid[j - 1].second)
      end1 = j;
    else {
      prod *= (end1 - start1 + 2);
      prod %= 1000000007;
      start1 = j;
      end1 = j;
    }
  }
  prod *= (end1 - start1 + 2);
  prod %= 1000000007;
  prod -= (end - start + 2);
  prod += 1000000007;
  sum += prod;
  sum %= 1000000007;
  cout << sum << endl;
}
