#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============modpow============================
ll modpow(ll a, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//=================================================

int main() {
  ll mod = 1000000007;
  ll N;
  cin >> N;
  map<pair<ll, ll>, pair<ll, ll>> m;//same, diff
  vector<ll> zero = {0, 0, 0};
  for (ll i = 0; i < N; ++i) {
    ll a, b;
    cin >> a >> b;
    if (a == 0 || b == 0) {
      if (a == 0 && b == 0) {
        zero.at(2) += 1;
      }
      else if (a == 0) {
        zero.at(0) += 1;
      }
      else {
        zero.at(1) += 1;
      }
      continue;
    }
    ll gcd = __gcd(a, b);
    a /= gcd;
    b /= gcd;
    ll abs_a = abs(a), abs_b = abs(b);
    pair<ll, ll> temp = {abs_a, abs_b};
    if ((a < 0 && b > 0) || (a > 0 && b < 0)) {
      m[temp].second += 1;
    }
    else {
      m[temp].first += 1;
    }
  }
  ll ans = 1;
  ll pow2 = 0;
  if (zero.at(0) == 0 || zero.at(1) == 0) {
    // pow2 += zero.at(0) + zero.at(1);
    ans = (ans * modpow(2, zero.at(0) + zero.at(1), mod)) % mod;
  }
  else {
    ans = (modpow(2, zero.at(0), mod) + modpow(2, zero.at(1), mod) - 1) % mod;
  }
  map<pair<ll, ll>, bool> already;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    pair<ll, ll> now = (*itr).second;
    if (already[(*itr).first]) {
      continue;
    }
    pair<ll, ll> opp = m[{(*itr).first.second, (*itr).first.first}];
    already[(*itr).first] = true;
    already[{(*itr).first.second, (*itr).first.first}] = true;
    if (now.first * opp.second == 0) {
      // pow2 += now.first + opp.second;
      ans = (ans * modpow(2, now.first + opp.second, mod)) % mod;
    }
    else {
      ll temp = (modpow(2, now.first, mod) + modpow(2, opp.second, mod) - 1) % mod;
      ans = (ans * temp) % mod;
    }
    if ((*itr).first.first == (*itr).first.second) {
      continue;
    }
    if (now.second * opp.first == 0) {
      // pow2 += now.second + opp.first;
      ans = (ans * modpow(2, now.second + opp.first,  mod) % mod);
    }
    else {
      ll temp = (modpow(2, now.second, mod) + modpow(2, opp.first, mod) - 1) % mod;
      ans = (ans * temp) % mod;
    }
    cout << "ans" << ans << "\n";
  }
  // ans = (ans * modpow(2, pow2, mod)) % mod;
  ans = (ans - 1 + zero.at(2)) % mod;
  // cout << (ans - 1 + zero.at(2)) % mod << "\n";
  if (ans < 0) {
    ans += mod;
  }
  cout << ans << "\n";
}
