//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct mint {
  ll x; // typedef long long ll;
  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;}
};
ll gcd(ll a, ll b ){
    ll r, tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    mint ans = mint(1);
    map<pair<ll,ll>, mint> mp;
    mint cnt00=mint(0);
    mint cnt01=mint(0);
    mint cnt10=mint(0);
    REP(i,n){
        ll a,b;
        cin >> a >> b;
        if(a==0&&b==0){
            cnt00 += mint(1);
        }else if(a==0){
            cnt01 += mint(1);
        }else if(b==0){
            cnt10 += mint(1);
        }else{
            ll ma=1,mb=1;
            if(a<0){
                ma=-1;
                a = -a;
            }
            if(b<0){
                mb=-1;
                b = -b;
            }
            ll gc = gcd(a,b);
            a/=gc;
            b/=gc;
            if(ma*mb<0){
                a=-a;
            }
            mp[make_pair(a,b)] += mint(0);
            if(a<0){
                mp[make_pair(b,-a)] += mint(1);
                //cout << b << "+" << -a << endl;
            }else{
                mp[make_pair(-b,a)] += mint(1);
                //cout << -b << "+" << a << endl;
            }
            //ans += ans - mint(mp[make_pair(a,b)])+mint(1);
            //cout << a << ":" << b << endl;
            //cout << ans.x << endl;
        }
    }
    for(auto p : mp){
        mint xi = p.se;
        ll ai = p.fi.fi;
        ll bi = p.fi.se;
        ll aj,bj;
        if(ai<0){
            aj = bi;
            bj = -ai;
        }else{
            aj = -bi;
            bj = ai;
        }
        mint xj = mp[make_pair(aj,bj)];
        mint two = mint(2);
        mint cnt = two.pow(xi.x) + two.pow(xj.x) - mint(1);
        ans *= (cnt);
        //ans += xi.x+xj.x;
        mp[make_pair(aj,bj)] = mint(0);
        mp[make_pair(ai,bi)] = mint(0);
        //cout << p.fi.fi << "~" << p.fi.se << "~" << xi << ":" << ans.x << endl;
    }
    {
        mint two = mint(2);
        mint cnt = two.pow(cnt10.x) + two.pow(cnt01.x) - mint(1);
        ans *= (cnt);
    }
    ans += cnt00;
    ans -= mint(1);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 28488