#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}


ll fact_mod(ll n) {
    ll ret=1; 
    for(ll i=2;i<=n;i++) ret=ret*(i%mod)%mod;
    return ret;
} 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}
//O(r)
ll combination_mod(ll n, ll r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    ll a=1;
    for(ll i=0;i<r;i++) a=a*((n-i)%mod)%mod;
    ll b=pow_mod(fact_mod(r), mod-2);
    return (a%mod)*(b%mod)%mod;
}
ll inv_mod(ll n){
    return pow_mod(n,mod-2);
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    vector<pair<ll,ll>> v(n);
    ll after=0;
    rep(i,n){
        cin>>v[i].first>>v[i].second;

        if(v[i].first==0 and v[i].second==0){
            after++;
        }
    }
    n-=after;

    // やくぶｎ，(分子，分母)　負なら，分子を負
    auto f=[](ll si,ll bo){
        if(si==0)return make_pair(0ll,1ll);
        if(bo==0)return make_pair(1ll,0ll);
        ll g=gcd(abs(si),abs(bo));
        si/=g;bo/=g;

        if(si>0 and bo>0) return make_pair(si,bo);
        if(si<0 and bo<0) return make_pair(abs(si),abs(bo));
        else return make_pair(-abs(si),abs(bo));
    };

    map<pair<ll,ll>,ll> cnt,cnt2;
    for(int i=0;i<n;i++){
        cnt[f(v[i].second,v[i].first)]++;  
        auto p=f(v[i].first,v[i].second);
        p.first=-p.first;
        cnt2[p]++;
    }

    vector<pair<ll,ll>> yabai;
    for(auto pp:cnt){
        auto p=pp.first;
        ll lf=pp.second;

        if(lf==0) continue;

        pair<ll,ll> target;
        if(p.first<0) target=make_pair(p.second,-p.first);
        else target=make_pair(-p.second,p.first);

        if(cnt.count(target)){

            if(cnt[target]) yabai.push_back(make_pair(lf,cnt[target]));
            cnt[target]=0;
        }
    }

    ll s=0;
    for(auto p:yabai) s+=p.first+p.second;
    ll ans=pow_mod(2,n-s);
    for(auto p:yabai){
        ll res=(pow_mod(2,p.first+p.second)+mod-(pow_mod(2,p.first)-1)*(pow_mod(2,p.second)-1)%mod)%mod;
        ans=ans*res%mod;
    }
    ans--;
    if(after) ans+=after-1;
    if(ans<0) ans+=mod;
    cout<<ans<<endl;
    return 0;
}
