#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M)%M;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<P> p,m;
    ll azero = 0,bzero = 0,a,b,p1 = 0,m1 = 0,zero = 0;
    rep(i,n){
        cin >> a >> b;
        if (a == 0 && b == 0){
            zero++;
        }
        else if (a == 0){
            azero++;
        }
        else if (b == 0){
            bzero++;
        }
        else if (a == b){
            p1++;
        }
        else if (a == -b){
            m1++;
        }
        else if ((a > 0 && b > 0) || (a < 0 && b < 0)){
            p.push_back(P(abs(a),abs(b)));
        }
        else{
            m.push_back(P(abs(a),abs(b)));
        }
    }
    map<P,ll> pu,pd,mu,md;
    vector<P> num;
    for(P q:p){
        tie(a,b) = q;
        ll k = gcd(a,b);
        a /= k;
        b /= k;
        if (a > b){
            num.push_back(P(a,b));
            pu[P(a,b)]++;
        }
        else if (a < b){
            num.push_back(P(b,a));
            pd[P(b,a)]++;
        }
    }
    for(P q:m){
        tie(a,b) = q;
        ll k = gcd(a,b);
        a /= k;
        b /= k;
        if (a > b){
            num.push_back(P(a,b));
            mu[P(a,b)]++;
        }
        else if (a < b){
            num.push_back(P(b,a));
            md[P(b,a)]++;
        }
    }
    SORT(num);
    num.erase(unique(all(num)),num.end());
    ll ans = (RepeatSquaring(2,p1,MOD)+RepeatSquaring(2,m1,MOD)+MOD-1)%MOD;
    for (P v:num){
        //cout << pu[v] << pd[v] << mu[v] << md[v] << endl;
        ans *= (RepeatSquaring(2,pu[v],MOD)+RepeatSquaring(2,md[v],MOD)-1)%MOD;
        ans %= MOD;
        ans *= (RepeatSquaring(2,pd[v],MOD)+RepeatSquaring(2,mu[v],MOD)-1)%MOD;
        ans %= MOD;
    }
    ans *= (RepeatSquaring(2,azero,MOD)+RepeatSquaring(2,bzero,MOD)+MOD-1)%MOD;
    PRINT((ans+zero+MOD-1)%MOD);
}


Measured memory_bytes: 59408