#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % 1000000007;
    }
    x = x * x % 1000000007;
    n >>= 1;
  }
  return res;
}
int main() {
  ll n;
  cin >> n;
  vector<pair<ll, ll> > num;
  map<pair<ll, ll>, ll> mp;
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    ll kouyaku = gcd(a, b);
    if (kouyaku != 0) {
      a = a / abs(kouyaku);
      b = b / abs(kouyaku);
    }
    auto itr = mp.find(pair<ll, ll>(a, b));
    if (itr != mp.end()) {
      mp[pair<ll, ll>(a, b)]++;
    } else {
      mp[pair<ll, ll>(a, b)] = 1;
    }
  }
  ll ans = 1;
  ll am = 0;
  ll abzero = 0;
  ll agazero = 0;
  ll bgazero = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    ll aite = 0;
    pair<ll, ll> tmp = itr->first;
    if (mp[tmp] == 0) {
      continue;
    }
    ll count = mp[tmp];
    ll aa = tmp.first;
    ll bb = tmp.second;
    if (aa == 0 && bb == 0) {
      abzero = mp[tmp];
      continue;
    } else if (aa == 0) {
      agazero += count;
      continue;
    } else if (bb == 0) {
      bgazero += count;
      continue;
    }
    int flag = 1;
    auto itrtmp = mp.find(pair<ll, ll>(aa * (-1), bb * (-1)));
    if (itrtmp != mp.end()) {
      count += mp[pair<ll, ll>(aa * (-1), bb * (-1))];
      mp[pair<ll, ll>(aa * (-1), bb * (-1))] = 0;
    }
    itrtmp = mp.find(pair<ll, ll>(bb, aa * (-1)));
    if (itrtmp != mp.end()) {
      aite += mp[pair<ll, ll>(bb, aa * (-1))];
      mp[pair<ll, ll>(bb, aa * (-1))] = 0;
      flag = 0;
    }
    itrtmp = mp.find(pair<ll, ll>(bb * (-1), aa));
    if (itr != mp.end()) {
      aite += mp[pair<ll, ll>(bb * (-1), aa)];
      mp[pair<ll, ll>(bb * (-1), aa)] = 0;
      flag = 0;
    }
    if (flag) {
      am += count;
    } else {
      ll tmptmp =
          (mod_pow(2, count) + mod_pow(2, aite) + 1000000007 - 1) % 1000000007;
      ans = ans * tmptmp % 1000000007;
    }
  }
  if (agazero && bgazero) {
    ans = ans *
          ((mod_pow(2, agazero) + mod_pow(2, bgazero) + 1000000007 - 1) %
           1000000007) %
          1000000007;
  } else {
    am += agazero + bgazero;
  }
  ans = ans * mod_pow(2, am) % 1000000007;
  if (abzero) {
    ans = ans * (abzero + 1) % 1000000007;
  }
  ans = (ans + 1000000007 - 1) % 1000000007;
  cout << ans << endl;
}
