There are a set of points *S* on the plane. This set doesn't contain the origin *O*(0, 0), and for each two distinct points in the set *A* and *B*, the triangle *OAB* has strictly positive area.

Consider a set of pairs of points (*P*<sub class="lower-index">1</sub>, *P*<sub class="lower-index">2</sub>), (*P*<sub class="lower-index">3</sub>, *P*<sub class="lower-index">4</sub>), ..., (*P*<sub class="lower-index">2*k* - 1</sub>, *P*<sub class="lower-index">2*k*</sub>). We'll call the set good if and only if:
 -  *k* ≥ 2. -  All *P*<sub class="lower-index">*i*</sub> are distinct, and each *P*<sub class="lower-index">*i*</sub> is an element of *S*. -  For any two pairs (*P*<sub class="lower-index">2*i* - 1</sub>, *P*<sub class="lower-index">2*i*</sub>) and (*P*<sub class="lower-index">2*j* - 1</sub>, *P*<sub class="lower-index">2*j*</sub>), the circumcircles of triangles *OP*<sub class="lower-index">2*i* - 1</sub>*P*<sub class="lower-index">2*j* - 1</sub> and *OP*<sub class="lower-index">2*i*</sub>*P*<sub class="lower-index">2*j*</sub> have a single common point, and the circumcircle of triangles *OP*<sub class="lower-index">2*i* - 1</sub>*P*<sub class="lower-index">2*j*</sub> and *OP*<sub class="lower-index">2*i*</sub>*P*<sub class="lower-index">2*j* - 1</sub> have a single common point. 
Calculate the number of good sets of pairs modulo 1000000007 (10<sup class="upper-index">9</sup> + 7).
The first line contains a single integer *n* (1 ≤ *n* ≤ 1000) — the number of points in *S*. Each of the next *n* lines contains four integers *a*<sub class="lower-index">*i*</sub>, *b*<sub class="lower-index">*i*</sub>, *c*<sub class="lower-index">*i*</sub>, *d*<sub class="lower-index">*i*</sub> (0 ≤ |*a*<sub class="lower-index">*i*</sub>|, |*c*<sub class="lower-index">*i*</sub>| ≤ 50; 1 ≤ *b*<sub class="lower-index">*i*</sub>, *d*<sub class="lower-index">*i*</sub> ≤ 50; (*a*<sub class="lower-index">*i*</sub>, *c*<sub class="lower-index">*i*</sub>) ≠ (0, 0)). These integers represent a point <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/eb0ead1a6138beb1ef687d910311920c2d9818fc.png" style="max-width: 100.0%;max-height: 100.0%;"/>.

No two points coincide.
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct frac {
  ll u, d;

  frac (ll _u = 0, ll _d = 1) {
    u = _u, d = _d;
    if (d) {
      ll g = __gcd(abs(u), abs(d));
      u /= g, d /= g;
      if (d < 0) u = -u, d = -d;
    } else {
      u = 1;
    }
  }

  frac operator + (const frac &f) const {
    return frac(u * f.d + d * f.u, d * f.d);
  }
  
  frac operator - (const frac &f) const {
    return frac(u * f.d - d * f.u, d * f.d);
  }

  frac operator * (const frac &f) const {
    return frac(u * f.u, d * f.d);
  }

  frac operator / (const frac &f) const {
    return frac(u * f.d, d * f.u);
  }

  bool operator < (const frac &f) const {
    return u * f.d < d * f.u;
  }
};

typedef pair <frac, frac> point;

#define x first
#define y second

const int N = 1010;
const int MOD = 1e9 + 7;

int n; point p[N];
map <point, vector <pair <int, int>>> mids;

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    ll a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    ll down = a * a * d * d + b * b * c * c;
    p[i] = point(frac(a * b * d * d, down), frac(c * d * b * b, down));
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      mids[point(p[i].x + p[j].x, p[i].y + p[j].y)].emplace_back(i, j);
    }
  }
  ll ans = 0;
  for (auto it : mids) {
    ll cur = 1;
    map <frac, int> slope;
    for (auto [i, j] : it.y) ++slope[(p[i].y - p[j].y) / (p[i].x - p[j].x)];
    for (auto i : slope) cur = cur * (1 + i.y) % MOD;
    ans += cur - it.y.size() - 1;
  }
  ans %= MOD, ans += MOD, ans %= MOD;
  cout << ans << '\n';
  return 0;
}

