#include<bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    unsigned long zeros{0};
    map<pair<unsigned long, unsigned long>, pair<unsigned long, unsigned long>> mp;
    for(unsigned long i{0}; i < N; ++i){
        long A, B;
        cin >> A >> B;
        if(A == 0 && B == 0){
            ++zeros;
            break;
        }
        auto g = gcd(A, B);
        A /= g;
        B /= g;
        unsigned long f = A * B < 0;
        if(A < 0){
            A *= -1;
            B *= -1;
        }
        if(B < 0){
            swap(A, B);
            A *= -1;
        }
        if(f)++mp[{A, B}].first;
        else++mp[{A, B}].second;
    }
    unsigned long ans{1};
    const auto& mod2pow = [](unsigned long a, unsigned long n) -> unsigned long {
        unsigned long r{a}, p{2};
        while(n){
            if(n & 1)(r *= p) %= 1000000007;
            (p *= p) %= 1000000007;
            n >>= 1;
        }
        return r;
    };
    for(const auto& [_, i] : mp){
        unsigned long k{mod2pow(ans, i.first)}, l{mod2pow(ans, i.second)};
        ans = (k + l + 1000000007 - ans) % 1000000007;
    }
    cout << (ans + 1000000006 + zeros) % 1000000007 << endl;
    return 0;
}