#include <bits/stdc++.h>
using namespace std;

#ifdef _LOCAL
  #include <debug.hpp>
  #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
  #define debug(...) 42
#endif

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vl2;
const bool multiple_queries = false;
#define rep(i, n) for(ll i = 0; i < (n) ; ++i)
#define For(i, a, b) for(ll i = (a); i < (b) ; ++i)
#define revrep(i, n) for(ll i = (n) - 1; i >= 0 ; --i)
#define revFor(i, b, a) for(ll i = (b) - 1; i >= (a) ; --i)
#define all(v) v.begin(), v.end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(i) __builtin_popcountl((i))
#define substring(s, start, end) s.substr((start), (end) - (start) + 1)

void print(){}
void println(){cout << endl;}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T>& vs){
  for (auto v: vs){
    cout << v;
    if (&v != &vs.back()) cout << " ";
  }
  cout << endl;
}

template <class Head, class... Tail>
void println(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  println(forward<Tail>(tail)...);
}

template <class T>
void println(vector<T>& vs){for (auto v: vs) cout << v << endl;}

ll gcd(ll m, ll n){
  ll a = max(m, n), b = min(m, n);
  while(b != 1 && b != 0){ a %= b; swap(a, b);}
  return b == 1 ? 1 : a;
}

const ll MOD = 1000000007;
// const ll MOD = 998244353;

struct mint {
  ll x;
  mint(ll 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(ll t) const{
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
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;}
string to_string(mint a){return to_string(a.x);}
typedef std::vector<mint> vmi;
typedef std::vector<vmi> vmi2;
typedef std::vector<vmi2> vmi3;
typedef std::vector<vmi3> vmi4;

struct PowerMemo{
  ll sz, mod, base;
  vl powB;

  PowerMemo(ll sz, ll base, ll _mod):
    sz(sz), base(base), mod(_mod){
      powB.resize(sz + 5);
      init();
    }

  void init(){
    powB[0] = 1;
    rep(i, sz + 3)
      powB[i + 1] = (powB[i] * base) % mod;
  }

  ll operator[](ll k){
    return powB[k];
  }
};

void solve(){
  ll n, cz = 0; mint ans = 1;
  cin >> n;
  PowerMemo p2(n + 5, 2, MOD);
  // ai / bi = - bj / aj
  map<pair<ll, ll>, pair<ll, ll>> cnt;
  rep(i, n){
    ll a, b, g;
    cin >> a >> b;
    if (!a && !b){++cz; continue;}
    else if (!a){++cnt[{1, 0}].first; continue;}
    else if (!b){++cnt[{1, 0}].second; continue;}

    g = abs(gcd(a, b));
    a /= g, b /= g;
    if ((a < 0 && b < 0) || (a > 0 && b > 0))
      ++cnt[{abs(a), abs(b)}].first;
    else
      ++cnt[{abs(b), abs(a)}].second;
  }

  for (auto& p: cnt){
    auto c = p.second;
    mint v1 = p2[c.first] - 1;
    mint v2 = p2[c.second] - 1;
    ans *= v1 + v2 + 1;
  }

  ans += cz - 1;
  println(ans);
}

void test(ll num = 0, bool verbose = false){
  rep(i, max(1LL, num)){
    ll t = clock();
    if (verbose) cout << "\n#####" << " " << i + 1 << " " << "#####" << " " << "\n## Answer ##\n";
    solve();
    if (verbose) {cout << "\nElapsed Time:" << " " << 1000.0 * (clock() - t) / CLOCKS_PER_SEC << " " << "[ms]" << endl;}
  }
}

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  #ifdef _LOCAL
    test(6, true);
  #else
    ll t = 0;
    if (multiple_queries) cin >> t;
    test(t, false);
  #endif
  return 0;
}

Measured memory_bytes: 20404