#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

#include <iostream>
using i64 = long long;
template<i64 M> struct modint { i64 a;
  constexpr modint(const i64 x = 0): a((x%M+M)%M){}
  constexpr i64 value() const { return a; }
  constexpr modint inv() const { return this->pow(M-2); }
  constexpr modint pow(i64 r) const {
    modint ans(1); modint aa = *this;
    while(r) { if(r & 1) ans *= aa; aa *= aa; r >>= 1; }
    return ans;
  }
  constexpr modint& operator=(const i64 r) { a = (r % M + M) % M; return *this; }
  constexpr modint& operator+=(const modint r) { a += r.a; if(a >= M) a -= M; return *this; }
  constexpr modint& operator-=(const modint r) { a -= r.a; if(a < 0) a += M; return *this; }
  constexpr modint& operator*=(const modint r) { a = a * r.a % M; return *this; }
  constexpr modint& operator/=(const modint r) { (*this) *= r.inv(); return *this; }
  constexpr modint operator+(const modint r) const { return modint(*this) += r; }
  constexpr modint operator-(const modint r) const { return modint(*this) -= r; }
  constexpr modint operator*(const modint r) const { return modint(*this) *= r; }
  constexpr modint operator/(const modint r) const { return modint(*this) /= r; }
  constexpr bool operator!=(const modint r) const { return this->value() != r.value(); }
};

template<const i64 M> std::ostream& operator<<(std::ostream& os, const modint<M>& m) { os << m.value(); return os; }


i64 gcd(i64 a, i64 b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

using fp = modint<(i64)(1e9 + 7)>;

int main() {
  i64 N;
  cin >> N;
  vector<i64> A(N);
  vector<i64> B(N);
  rep(i,0,N) {
    cin >> A[i] >> B[i];
  }

  fp ans(0);

  using P = std::pair<i64, i64>;
  map<P, std::pair<i64, i64>> mp;
  std::vector<P> vec(N);

  rep(i,0,N) {
    if(A[i] == 0 && B[i] == 0) {
      continue;
    }
    else if(A[i] == 0) {
      B[i] = 1;
      vec[i] = { A[i], B[i] };
    }
    else if(B[i] == 0) {
      A[i] = -1;
      vec[i] = { A[i], B[i] };
    }
    else {
      i64 g = gcd(std::abs(A[i]), std::abs(B[i]));
      A[i] /= g;
      B[i] /= g;
      if(B[i] < 0) {
        A[i] *= -1;
        B[i] *= -1;
      }
      vec[i] = { A[i], B[i] };
    }
    auto p = vec[i];
    std::swap(p.first, p.second);
    p.first *= -1;
    if(p.second < 0) {
      p.second *= -1;
      p.first *= -1;
    }
    if(mp.count(vec[i])) {
      mp[vec[i]].first += 1;
    }
    else if(mp.count(p)) {
      mp[p].second += 1;
    }
    else {
      mp[vec[i]] = { 1, 0 };
    }
  }
  ans = fp(1);
  for(auto p: mp) {
    i64 A = p.second.first;
    i64 B = p.second.second;
    //std::cout << p.first.first << " : " << p.first.second << " = " << A << " " << B << std::endl;
    ans *= (fp(2).pow(A) + fp(2).pow(B) - 1);
  }
  cout << ans - 1 << endl;
}
