#include <bits/stdc++.h>

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最小公倍数

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1000000007;
using mint = Fp<MOD>;
int main(){
  ll N;
  cin>>N;
  map<ll,map<ll,ll>> m;
  vector<pair<ll,ll>> p(N);
  mint ans(1);
  for(int i(0);i<N;i++){
    ll a,b;
    cin>>a>>b;
    if(a == 0 && b == 0){
      ans += 1;
      continue;
    }
    if(a == 0){
      b = 1;
    }else if(b == 0){
      a = 1;
    }else{
      if(a < 0 && b < 0){
        a *= -1;
        b *= -1;
      }else if(a < 0 && b > 0){
        a *= -1;b*=-1;
      }
      ll kouyakusuu = gcd(abs(a),abs(b));
      if(kouyakusuu != 0){
        a /= kouyakusuu;
        b /= kouyakusuu;
      }
    }
    //cout << a << " " << b << endl;
    m[a][b]++;
    p[i] = {a,b};
  }
  for(int i(0);i<N;i++){
    ll a = p[i].first,b = p[i].second;
    if(m[a][b] && a>=0 && b>=0){
      ll tmp(0);
      tmp += m[a][b] + m[b][-a] + 1; //一個
      tmp %= MOD;
      if(m[a][b] >= 2) tmp += (m[a][b]*(m[a][b]-1)/2)%MOD;
      if(m[b][-a] >= 2) tmp += (m[b][-a]*(m[b][-a]-1)/2)%MOD;
      ans *= tmp;
      m[a][b] = 0;
      m[b][-a] = 0;
  //    cout << ans << endl;
    }
  }
  for(auto mi:m){
    for(auto mii:mi.second){
      ans *= (mii.second+1);
    }
  }
  if(ans != 0) ans -= 1;
  cout << ans << endl;
  return 0;
}

