#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long mod = 1e9 + 7;
    vector<long long>power(n + 3);
    power[0] = 1;
    for(int i = 1; i <= n; i++){
        power[i] = (power[i - 1] * 2) % mod;
    }
    map<pair<long long, long long>, int>mp;
    set<pair<long long, long long> >st;
    long long cnt = 0, cnt2 = 0, cnt3 = 0;
    for(int i = 1; i <= n; i++){
        long long a, b;
        cin >> a >> b;
        if(a == 0 && b == 0){
            cnt++;
        }
        else if(a == 0){
            cnt2++;
        }
        else if(b == 0){
            cnt3++;
        }
        else{
            long long x = abs(a);
            long long y = abs(b);
            long long z = __gcd(x, y);
            a = a/z;
            b = b/z;
            //cout << a << ' ' << b << '\n';
            mp[make_pair(a, b)]++;
            mp[make_pair(-a, -b)]++;
            st.insert(make_pair(a, b));
            st.insert(make_pair(-a, -b));
        }
    }
    long long ans = 1;
    map<pair<long long, long long>, int>::iterator it;
    for(it = mp.begin(); it != mp.end(); it++){
        pair<long long, long long>p = it->first;
        if(st.find(p) == st.end()){
            continue;
        }
        long long a = p.first, b = p.second;
        int val = it->second;
        long long cur = power[val];
        if(st.find(make_pair(-b, a)) == st.end()){
            ans = (ans * cur) % mod;
            st.erase(p);
            st.erase(make_pair(-a, -b));
        }
        else{
            int x = mp[make_pair(-b, a)];
            cur = (cur + power[x] + 2 * mod - 1) % mod;
            ans = (ans * cur) % mod;
            st.erase(p);
            st.erase(make_pair(-a, -b));
            st.erase(make_pair(-b, a));
            st.erase(make_pair(b, -a));
        }
    }
    ans = (ans * (cnt + 1)) % mod;
    if(cnt2 > 0 && cnt3 > 0){
        long long x = (power[cnt2] + power[cnt3] + 3 * mod - 1) % mod;
        ans = (ans * x) % mod;
    }
    else if(cnt2 > 0){
        ans = (ans * power[cnt2]) % mod;
    }
    else if(cnt3 > 0){
        ans = (ans * power[cnt3]) % mod;
    }
    cout << (ans + mod - 1) % mod;
    return 0;
}