#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
const int mod = 1000000007;
struct mint {
  long long x;
  mint(long long x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
long long N, A, B, zero, A0, B0;
mint ans;
map<pair<long long, long long>, int> iwashi;
int main() {
  cin >> N;
  vector<long long> a(N), b(N);
  for (int i = 0; i < N; i++) {
    cin >> A >> B;
    if (A == 0LL && B == 0LL) {
      zero++;
      continue;
    }
    if (A == 0LL) A0++;
    if (B == 0LL) B0++;
    while (gcd(A, B) != 1) {
      long long d = gcd(A, B);
      A /= d;
      B /= d;
    }
    iwashi[make_pair(A, B)]++;
    a[i] = A, b[i] = B;
  }
  ans += zero;
  ans += A0 * (N - B0);
  ans += B0 * (N - A0);
  N -= (zero + A0 + B0);
  for (int i = 0; i < N; i++) {
    int no = 0;
    no += iwashi[make_pair(-b[i], a[i])];
    no += iwashi[make_pair(b[i], -a[i])];
    mint ok = 2;
    ok = ok.pow(N - no - i - 1);
    ans += ok;
    iwashi[make_pair(a[i], b[i])]--;
  }
  cout << ans << endl;
  return 0;
}
