/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x % MOD, n/2);
    if(n % 2 == 1) res = res * x % MOD;
    return res;
}

void solve(){
    ll N;
    cin >> N;
    ll A[200010], B[200010];
    rep(i,0,N) cin >> A[i] >> B[i];
    map<lpair,ll> mp;
    vector<lpair> lp;
    rep(i,0,N){
        if(A[i] == 0 && B[i] == 0){
            continue;
        }else if(A[i] == 0){
            mp[{0,1}]++;
            lp.push_back({0,1});
        }else if(B[i] == 0){
            mp[{1,0}]++;
            lp.push_back({1,0});
        }else{
            ll v = gcd(abs(A[i]),abs(B[i]));
            A[i] /= v;
            B[i] /= v;
            if(A[i] < 0 && B[i] < 0){
                A[i] *= -1;
                B[i] *= -1;
            }

            mp[{A[i], B[i]}]++;
            lp.push_back({A[i],B[i]});
        }
    }
    sort(lp.begin(), lp.end(), [](lpair l1, lpair l2){
        return min(l1.first, l1.second) > min(l2.first, l2.second);
    });
    
    ll ans = 1;
    map<lpair, ll> check;
    
    for(auto &e: lp){
        lpair l1 = e;
        if(check[l1]) continue;
        check[l1]++;
        ll n = mp[l1];
        lpair l2;
        // print("===");
        // print(l1.first, l1.second);
        if(l1.first > 0 && l1.second > 0){
            // どっちも正
            l2 = {l1.second, -l1.first};
            // print(l2.first, l2.second);
            check[l2]++;
            ll v1 = mp[l2];
            l2 = {-l1.second, l1.first};
            // print(l2.first, l2.second);
            check[l2]++;
            ll v2 = mp[l2];
            ll v = power(2,n) + power(2,v1) + power(2,v2) - 2 + MOD;
            v %= MOD;
            ans *= v;
            ans %= MOD;

        }else{
            // どっちか負
            lpair l2 = {l1.second, -l1.first};
            ll v = power(2,n) + power(2,mp[l2]) - 1 + MOD;
            v %= MOD;
            ans *= v;
            ans %= MOD;
        }
        
        // check[l2]++;
        // if(mp[l2] == 0){
        //     // print(l1.first, l1.second);
        //     ll v = power(2, n);
        //     ans *= v;
        //     ans %= MOD;
        // }else{
        //     ll v = power(2,n) + power(2,mp[l2]) - 1 + MOD;
        //     v %= MOD;
        //     ans *= v;
        //     ans %= MOD;
        // }
        // check[l1]++;

    }
    ans = (ans - 1 + MOD) % MOD;
    print(ans);

    

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}